From d889352941e85880fecaa7f061fe0934b9e979f7 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 3 Feb 2018 23:29:59 -0500 Subject: [PATCH] GUACAMOLE-499: Have RESTExceptionWrapper leverage HTTP status codes built into GuacamoleStatus. --- .../guacamole/rest/RESTExceptionWrapper.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/RESTExceptionWrapper.java b/guacamole/src/main/java/org/apache/guacamole/rest/RESTExceptionWrapper.java index 6f1ab371f..28736e8de 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/RESTExceptionWrapper.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/RESTExceptionWrapper.java @@ -171,17 +171,11 @@ public class RESTExceptionWrapper implements MethodInterceptor { } // Translate GuacamoleException subclasses to HTTP error codes - catch (GuacamoleSecurityException e) { - throw new APIException(Response.Status.FORBIDDEN, e); - } - catch (GuacamoleResourceNotFoundException e) { - throw new APIException(Response.Status.NOT_FOUND, e); - } - catch (GuacamoleClientException e) { - throw new APIException(Response.Status.BAD_REQUEST, e); - } catch (GuacamoleException e) { - throw new APIException(Response.Status.INTERNAL_SERVER_ERROR, e); + throw new APIException( + Response.Status.fromStatusCode(e.getStatus().getHttpStatusCode()), + e + ); } // Rethrow unchecked exceptions such that they are properly wrapped