7
How do I get the controller to automatically return a replay to the client in JSON format instead of HTML in case of an error (e. g. error 404, 500, 419, etc.). For example, if there is error 500 in Laravel, I would like it to return as follows:
{status: 500,
message: "Trying to get id os non object at UserController.php line 150"
trace: {...}
}
I realized that this is already done in the Web application routes (web.php) when making an internal request in Ajax. I’m assembling an Android application that requests in my web application, which is being used as a Webservice, and I’m not able to handle the errors, because they are being returned in HTML format (Document). Thanks for your help.
already tried to edit the App/Exception/Handler? you can modify it and return a replay with the data you want!
– Lodi