Skip to content
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

Report message from response.sendError(int,String) in BasicErrorController #1762

Closed
dsyer opened this issue Oct 27, 2014 · 7 comments
Closed
Labels
type: enhancement A general enhancement
Milestone

Comments

@dsyer
Copy link
Member

dsyer commented Oct 27, 2014

The BasicErrorController doesn't look in the request attributes for a message if the exception is non-null, even if the message from the exception was empty or null. Arguably the message from sendError() should take precedence over an exception anyway (it's available as a request attribute, according to the servlet spec).

@dsyer dsyer added the type: enhancement A general enhancement label Oct 27, 2014
@dsyer dsyer added this to the 1.2.0.RC1 milestone Oct 27, 2014
@wilkinsona
Copy link
Member

Arguably the message from sendError() should take precedence over an exception anyway (it's available as a request attribute, according to the servlet spec).

I agree. See #1731. Changing the precedence would fix that issue.

@chornyi
Copy link

chornyi commented Dec 15, 2015

Did you consider making the precedence configurable? As it is now, when using the JSR-303 validations, all the caller gets is a BadRequest message with no details on which field is invalid. Or am I missing something and there is a way to get that information without writing custom error handlers?

@wilkinsona
Copy link
Member

@chornyi If you don't like the defaults, you can provide your own ErrorAttributes bean.

@dsyer
Copy link
Member Author

dsyer commented Dec 15, 2015

I don't think using JSR-303 per se will prevent you from seeing detailed field level errors (that's precisely the change we made here), but it might depend on how you are using it, whether that nformation is available at all. In any case I doubt if the change made here would have hidden any information, so reversing the priority wouldn't help you, unless I'm missing something. If you have an issue with the current code, please open a new ticket, anyway, and refer to this one if you need to.

@joseluis10101
Copy link

joseluis10101 commented Apr 15, 2021

@dsyer A while ago we implemented using 2.2 and including the message on sending worked very well, later we updated to Spring 2.4 but the message stopped being included in the response, I just verified that it also happens with 2.3.

My mistake, i just found that from SB 2.3 that is configurable by "server.error.include-message" parameter.

@dsyer
Copy link
Member Author

dsyer commented Apr 15, 2021

There’s not much point in commenting here. If there’s a behaviour change in recent versions it’s probably intentional, but open a new issue if you want to discuss.

@snicoll
Copy link
Member

snicoll commented Apr 15, 2021

@dsyer they updated their comment as they found the solution in the meantime. It's unrelated to this and a change of visibility in Spring Boot that is documented in the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants