-
-
Notifications
You must be signed in to change notification settings - Fork 137
feat(router): support giving back json when a request fail #1629
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
base: main
Are you sure you want to change the base?
feat(router): support giving back json when a request fail #1629
Conversation
brendt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add tests for this?
| $throwable instanceof CsrfTokenDidNotMatch => $this->renderErrorResponse(Status::UNPROCESSABLE_CONTENT), | ||
| default => $this->renderErrorResponse(Status::INTERNAL_SERVER_ERROR), | ||
| $request->accepts(ContentType::HTML, ContentType::XHTML) => $this->handleHtml($throwable), | ||
| $request->accepts(ContentType::JSON) => $this->jsonHandler->render($throwable), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we have HtmlHttpExceptionRenderer then for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely!
Would it make sense to remove the DeveloperExceptionHandler and in the HtmlHttpExceptionRenderer handle to show either whooosh or the custom view?
Tests for this (entire PR) is on my todo 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to remove the DeveloperExceptionHandler and in the HtmlHttpExceptionRenderer handle to show either whooosh or the custom view?
Maybe, but I'd say out of scope for this PR?
|
Wanted to check up: what needs to be done for this one, and can I help? Just want to make sure we don't loose track: it's a good feature and I'd like to see it merged 👍 |
Hi, I haven't had a lot of time (nor energy tbh) the last few weeks, but I do have some stuff locally that I'll clean up and push up asap :) Whats left:
And I did try to remove the |
Fixes #1619
Okay, so this is very wip, but I wanted to get it out to see if I'm thinking about this correctly before doing more work on this 🙂
The error "shape" is taken from Laravel, which I think it is pretty easy to work with:
invalid & generic.
But it should probably be discussed how it should look (maybe problem details or some other easier "standard").
EDIT:
Another thing im thinking about is this:
Maybe the errors that are handled by the middleware (in
forward) shouldn't be cast toHttpRequestFailed?ConvertsToResponse,ValidationFailedandRouteBindingFailed.