Initial Commit
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
package net.locusworks.common.exceptions;
|
||||
|
||||
/***
|
||||
* Custom exception class for the patch repository
|
||||
* @author Isaac Parenteau
|
||||
*
|
||||
*/
|
||||
public class ApplicationException extends Exception {
|
||||
private final Integer code;
|
||||
boolean success = false;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static ApplicationException egregiousServer() {
|
||||
return new ApplicationException(9001, "Something went wrong. Please see logs for details");
|
||||
}
|
||||
|
||||
public static ApplicationException invalidCreds() {
|
||||
return new ApplicationException(9001, "Invalid credentials provided");
|
||||
}
|
||||
|
||||
public static ApplicationException notLoggedIn() {
|
||||
return new ApplicationException(9002, "Not logged in");
|
||||
}
|
||||
|
||||
public static ApplicationException invalidEmailAddress() {
|
||||
return new ApplicationException(9005, "Invalid email address");
|
||||
}
|
||||
|
||||
public static ApplicationException actionNotPermitted() {
|
||||
return new ApplicationException(9007, "Action not permitted");
|
||||
}
|
||||
|
||||
public static ApplicationException actionNotPermitted(String message) {
|
||||
return new ApplicationException(9007, "Action not permitted: " + message);
|
||||
}
|
||||
|
||||
public static ApplicationException passwordsNotEqual() {
|
||||
return new ApplicationException(9008, "Passwords do not match");
|
||||
}
|
||||
|
||||
public static ApplicationException unAuthorized() {
|
||||
return new ApplicationException(9009, "unauthorized");
|
||||
}
|
||||
|
||||
public static ApplicationException duplicateEntry(String message) {
|
||||
return new ApplicationException(9100, message);
|
||||
}
|
||||
|
||||
public static ApplicationException duplicateEntry(String messageFmt, Object... args) {
|
||||
return new ApplicationException(9100, String.format(messageFmt, args));
|
||||
}
|
||||
|
||||
public static ApplicationException noEntryExists(String message) {
|
||||
return new ApplicationException(9101, message);
|
||||
}
|
||||
|
||||
public static ApplicationException noEntryExists(String messageFmt, Object... items) {
|
||||
return new ApplicationException(9101, String.format(messageFmt, items));
|
||||
}
|
||||
|
||||
public static ApplicationException constraintViolation(String message) {
|
||||
return new ApplicationException(9102, message);
|
||||
}
|
||||
|
||||
public static ApplicationException constraintViolation(String messageFmt, Object... items) {
|
||||
return new ApplicationException(9102, String.format(messageFmt, items));
|
||||
}
|
||||
|
||||
public static ApplicationException illegalArgument(String message) {
|
||||
return new ApplicationException(9103, message);
|
||||
}
|
||||
|
||||
public static ApplicationException generic(String message) {
|
||||
return new ApplicationException(9999, message);
|
||||
}
|
||||
|
||||
public static ApplicationException fromException(Throwable e) {
|
||||
return new ApplicationException(9999, e);
|
||||
}
|
||||
|
||||
public ApplicationException(int code, Throwable e) {
|
||||
this(code, e.getMessage(), e);
|
||||
}
|
||||
|
||||
public ApplicationException(int code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ApplicationException(int code, String message, Throwable e) {
|
||||
super(message, e);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user