diff --git a/guacamole-common/src/main/java/org/apache/guacamole/GuacamoleException.java b/guacamole-common/src/main/java/org/apache/guacamole/GuacamoleException.java index 44d40e3ad..d9842266d 100644 --- a/guacamole-common/src/main/java/org/apache/guacamole/GuacamoleException.java +++ b/guacamole-common/src/main/java/org/apache/guacamole/GuacamoleException.java @@ -80,5 +80,17 @@ public class GuacamoleException extends Exception { public int getHttpStatusCode() { return getStatus().getHttpStatusCode(); } + + /** + * Returns the most applicable WebSocket status code that can be + * associated with this exception. + * + * @return + * An integer representing the most applicable WebSocket status + * code associated with this exception. + */ + public int getWebSocketCode() { + return getStatus().getWebSocketCode(); + } } 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 28736e8de..a0c756ebe 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/RESTExceptionWrapper.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/RESTExceptionWrapper.java @@ -173,7 +173,7 @@ public class RESTExceptionWrapper implements MethodInterceptor { // Translate GuacamoleException subclasses to HTTP error codes catch (GuacamoleException e) { throw new APIException( - Response.Status.fromStatusCode(e.getStatus().getHttpStatusCode()), + Response.Status.fromStatusCode(e.getHttpStatusCode()), e ); }