diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIErrorResponse.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIErrorResponse.java index ee7d4fd..935c27a 100644 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIErrorResponse.java +++ b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIErrorResponse.java @@ -52,6 +52,13 @@ public class APIErrorResponse { this.message = getLocalizedMessage(apiError, locale); this.rootCause = th.getMessage(); } + + public APIErrorResponse(APIError apiError, Locale locale, String rootCauseMessage) { + this.status = apiError.getStatus(); + this.errorCode = apiError.getErrorCode(); + this.message = getLocalizedMessage(apiError, locale); + this.rootCause = rootCauseMessage; + } public APIErrorResponse(Exception exception, Locale locale) { this.status = Response.Status.INTERNAL_SERVER_ERROR; diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java index e122237..10e5cfc 100644 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java +++ b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java @@ -29,6 +29,7 @@ public class APIException extends RuntimeException { public static final String HTTP_HEADER_X_ERROR = "X-Error"; public static final String HTTP_HEADER_X_ERROR_CODE = "X-Error-Code"; public static final String HTTP_HEADER_X_ROOT_CAUSE = "X-Root-Cause"; + private static final long serialVersionUID = -4356132354448841938L; private final Response httpResponse; @@ -39,6 +40,10 @@ public class APIException extends RuntimeException { public APIException(APIError apiError, Locale locale, Throwable th) { httpResponse = createHttpResponse(new APIErrorResponse(apiError, locale, th)); } + + public APIException(APIError apiError, Locale locale, String rootCause) { + httpResponse = createHttpResponse(new APIErrorResponse(apiError, locale, rootCause)); + } public APIException(Exception exception, Locale locale) { httpResponse = createHttpResponse(new APIErrorResponse(exception, locale));