How does Laravel write a front method similar to thinkphp?

when I query a user"s information, including editing a user"s information
when the user exists and there is no such data time in the database, Laravel reported me such an error

(2amp 2) NotFoundHttpException
No query results for model [AppModelUser].

data has not been queried, how can we mask this error?
I am a novice!

my own solution is these three

  • add a try catch to each execution function
  • use _ _ controuct to detect the existence of data
  • use a front method

could you tell me how to solve this problem?

May.01,2021

  1. I suggest you take a closer look at the official documents
  2. Error Handling learn about

show code.


data is not queried first to see why it has not been queried, rather than to mask this error. If you want to change the error display type, use Exception Handler


The reason for this error is that instead of using dependency injection, I used the form of passing parameters and did not get the id of the user who needs to be queried

the front-end method is that laravel provides middleware, which can be used,

Thank you for your answers


data does not exist is should throw 404 ah, do not understand what you said in thinkphp is how to operate.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea9f0b-46cda.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea9f0b-46cda.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?