Defining the exception response structure

Let's create a bean to define the structure of our custom exception message. 

We have created the following simple exception response bean with an auto-populated timestamp and a few additional properties, namely messages and details:

    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;
}

}

When TodoNotFoundException is thrown, we want to return a response using the ExceptionResponse bean.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset