Skip to content

Instantly share code, notes, and snippets.

@sampathsl
Created September 24, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sampathsl/a093f750237263ec257166cd72bbb3ec to your computer and use it in GitHub Desktop.
Save sampathsl/a093f750237263ec257166cd72bbb3ec to your computer and use it in GitHub Desktop.
Spring boot overriding the default white label error template with custom object
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