Skip to content

Instantly share code, notes, and snippets.

@abdulbasitkay
Last active May 10, 2017 20:41
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 abdulbasitkay/290842de0931ca8ecfae8d121f7af433 to your computer and use it in GitHub Desktop.
Save abdulbasitkay/290842de0931ca8ecfae8d121f7af433 to your computer and use it in GitHub Desktop.
// .... imports ommited for brevity
public class ErrorEntity implements Serializable {
int status; // contains the same HTTP Status code returned by the server
String message; // message describing the error
String developerMessage; // extra information that might useful for developers
public ErrorEntity(int status, Exception ex) {
StringWriter errorStackTrace = new StringWriter();
ex.printStackTrace(new PrintWriter(errorStackTrace));
this.developerMessage = errorStackTrace.toString();
this.status = status;
this.message = ex.getMessage();
}
public ErrorEntity(String message) {
this.status = Response.Status.BAD_REQUEST.getStatusCode();
this.message = message;
this.developerMessage = message;
}
// getters and setters ....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment