I have been able to generate an error message in my response JSON with the application property server.error.include-message=always
, but my understanding is that I should be to use "on-param" to only display a message if an error is accompanied by a parameter which they all are.
I've tried both a string parameter and a getMessage()
call and both work with "always," but never with "on-param."
Ex.
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "This is a bad request")
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage())
Looking for:
{
"timestamp":"2023-01-01T12:00:000+00:00",
"status": 400,
"error":"Bad Request",
"message":"This is a bad request",
"path":"/projectpath"
}
I would rather use "on-param" instead of "always" given the reason it was changed by Spring to default to "never" in the first place, to try to avoid accidentally revealing too much to a user, but does it matter if there is always a parameter accompanying the error anyway?
Ultimately, I haven't been able to find any insight online as to why using "always" works and "on-param" doesn't so any help is appreciated.