-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Core: Adding additional information in RestException #14927
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?
Conversation
| } | ||
|
|
||
| throw new RESTException("Unable to process: %s", error.message()); | ||
| throw new RESTException( |
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.
while we are here can we also add error code and type in
| throw new RESTException("Unable to process: %s", error.message()); |
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.
But here it's clear because this exception is triggered when the code is 422, which is Unprocessable Entity, then the current message for me is enough.
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.
IMHO its more about consistency than enhancing, for example we can say all the rest exception follow this pattern, since we don't have defined exception for it, it would be great to have this consistently have an error message format, WDYT ?
| throw new RESTException("Unable to process: %s", error.message()); | ||
| throw new RESTException( | ||
| "Unable to process (code: %s, type: %s): %s", | ||
| error.code(), error.type() != null ? error.type() : "unknown", error.message()); |
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.
i wonder if making the null as unknown adds more value ? how about just having error.type() ?
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.
Agree
There are scenarios where there are
RESTExceptionissues but the message is providing value. For instance:So, the idea is to provide
codeandtypeinRESTExceptionto get more context.