Let's look at how to customize the preceding exception and return the proper response status with a customized message.
Let's create a bean to define the structure of our custom exception message:
public class ExceptionResponse { private Date timestamp = new Date(); private String message; private String details; public ExceptionResponse(String message, String details) { super(); this.message = message; this.details = details; } public Date getTimestamp() { return timestamp; } public String getMessage() { return message; } public String getDetails() { return details; } }
We have created a simple exception response bean with an auto-populated timestamp with a few additional properties namely messages and ...