-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Add Javadoc to MvcResult getResponse().getErrorMessage() #31386
Comments
This
Maybe you would like to send a PR to add a Javadoc section for this method to disambiguate the current state of things? Thanks! |
I am not sure I understand your response correctly. We are not calling the
And rethrow it in the GlobalExceptionHandler:
Now that the automatic ResponseStatusException handling has changed to ProblemDetail like described here: https://stackoverflow.com/questions/75029947/error-response-body-changed-after-boot-3-upgrade we had to change our tests for these cases and manually parsing the JSON to get the error message. |
Yes, I understand. Previously, letting an exception unhandled would reach the Servlet container as Lines 137 to 148 in a53d3f3
Here, the error is instead rendered as a ProblemDetail JSON response, so the
I think this is the right approach. Feel free to create another issue if you have ideas on how to improve this. I think we'll reuse this issue to add the missing javadoc on this method. |
We are currently in the middle of migrating to spring 6 (via Spring Boot 3)
In Spring 5 we checked the error Message in SpringBoot Tests like this:
Now with the change to ErrorDetail weg cannot get the error Message via the getErrorMessage() Method:
Now the workaround would be validate the JSON and get the detail field manually, but I would expect the MockMvc Result to handle this. Otherwise the get ErrorMessage is highly misleading. Or am I misunderstanding something here?
The text was updated successfully, but these errors were encountered: