Created
September 24, 2018 05:02
-
-
Save sampathsl/a093f750237263ec257166cd72bbb3ec to your computer and use it in GitHub Desktop.
Spring boot overriding the default white label error template with custom object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExceptionResponse { | |
private Integer status; | |
private String path; | |
private String errorMessage; | |
private String timeStamp; | |
private String trace; | |
public ExceptionResponse(int status, Map<String, Object> errorAttributes) { | |
this.setStatus(status); | |
this.setPath((String) errorAttributes.get("path")); | |
this.setErrorMessage((String) errorAttributes.get("message")); | |
this.setTimeStamp(errorAttributes.get("timestamp").toString()); | |
this.setTrace((String) errorAttributes.get("trace")); | |
} | |
public Integer getStatus() { | |
return status; | |
} | |
private void setStatus(Integer status) { | |
this.status = status; | |
} | |
public String getErrorMessage() { | |
return errorMessage; | |
} | |
private void setErrorMessage(String errorMessage) { | |
this.errorMessage = errorMessage; | |
} | |
public String getTimeStamp() { | |
return timeStamp; | |
} | |
private void setTimeStamp(String timeStamp) { | |
this.timeStamp = timeStamp; | |
} | |
public String getTrace() { | |
return trace; | |
} | |
private void setTrace(String trace) { | |
this.trace = trace; | |
} | |
public String getPath() { | |
return path; | |
} | |
private void setPath(String path) { | |
this.path = path; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment