Skip to content

Make DefaultErrorAttributes easier to subclass for message customization #22378

@ldwqh0

Description

@ldwqh0

I have an exception like this

@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public class RequestValidationException extends RuntimeException {

    private static final long serialVersionUID = -3157465183026609933L;

    public RequestValidationException() {
        super();
    }

    public RequestValidationException(String message) {
        super(message);
    }
}

And then ,I throw the exception in a controller

throw new RequestValidationException("some message");

if I use tomcat containner ,the response is like this

{
    "timestamp": "2020-07-17T09:22:41.845+0000",
    "status": 400,
    "error": "Bad Request",
    "message": "some message",
    "path": "/oauth/token"
}

but if I use undertow or jetty containner ,the response is like this

{
    "timestamp": "2020-07-17T09:22:41.845+0000",
    "status": 400,
    "error": "Bad Request",
    "message": "Bad Request",
    "path": "/oauth/token"
}

there is different with message field.

I think it a Bug.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions