I use Laravel with ajax, and in my controller I have a try-catch block:
try { something... } catch (\Exception $e) { return response()->json([ 'status' => 'error', 'message'=> 'error message' ]); }
I use this to show an error message in a div on the page.
This works, but not if the error is an internal server 500 error (example: tokenmismatchexception).
Then the error does not fall into the catch block, and, in fact, the user is not notified of any error (except for the console).
Is there a way I can catch such errors and display the error in the same div that I usually do?
source share