HI, how do i handle exceptions?
I must block ability to return error content (message, line, trace, file) to just something like 500 message: api error, and log the context to laravel.log or db. i want a global one, i don't want to have try catch blocks in every functions. i had a working code in laravel 10 but in 12 there is not even an exception.php file ...
Laravel treats exceptions fine by default: set APP_DEBUG=false in .env and you will see only 500 (404, 403.. depends on the error itself) without specific error messages. The exception message itself is logged in storage/logs/laravel.log along with a backtrace, you can analyze the error there.
So, in simple case you don't have to handle them at all, just have APP_DEBUG=false and Laravel does the rest.
@martinbean i want users to get time of error and error message on staging version and only hide it on production. i dont like the default behaviour of it. Also i want to insert the error to database. So it not really fine how it is handled by default.