-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception Handling with Laravel 11.x #284
Comments
Thanks for reporting, I hadn't realised they'd removed the app's exception handler. I'll have to look into this as I don't know the answer without looking at how they now expect you to register exception renderers now. |
To make it work currently I re-created And in
This makes it return the Exceptions in json:API format. Not sure if that's the right way to go about it tho. As an example, when querying a resource with a non-eisting id
It seems it's returning detail for the I'm not sure if that's the correct behavior or not. |
@LucindaX thanks for sharing your temp. fix 👍 |
maybe something like this: https://laravel.com/docs/11.x/errors#renderable-exceptions |
Was looking at this the other day. This looks like the solution: ->withExceptions(function (Exceptions $exceptions) {
$exceptions->render(
\LaravelJsonApi\Exceptions\ExceptionParser::renderer(),
);
}) Would be good if someone could try that as my apps are still on Laravel 10. |
Looks good:
|
Great, thanks so much for confirming. I'll leave this issue open so I don't forget to update the docs. |
@lindyhopchris For the record, I'm using this configuration and it also seems to work so far: ->withExceptions(function (Exceptions $exceptions) {
$exceptions->dontReport([
JsonApiException::class,
]);
$exceptions->renderable(\LaravelJsonApi\Exceptions\ExceptionParser::make()->renderable());
}) I have not looked into this further and maybe this is just more verbose/redundant? |
I've spent 3 hours investigating why errors are not working! Last comment from tsterker works well and seems compatible with Laravel 11 documentation. It is only required changes in the documentation of the plugin. |
Docs are now updated: |
Exception handling is mentioned in the installation portion of the tutorial-app https://laraveljsonapi.io/docs/3.0/getting-started/#exception-handler
In Laravel 11.x that default Handler is removed, and instead
bootstrap/app.php
is supposed to be used as inHow do I set up the laravel-json-api Exception Handling in laravel 11.x
The text was updated successfully, but these errors were encountered: