GUACAMOLE-504: Rework HTTP Tunnel to use exception getHttpStatusCode()

Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/5aaea07b
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/5aaea07b
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/5aaea07b

Branch: refs/heads/master
Commit: 5aaea07b5ea5672b9acbeb27aa019a13178f0d96
Parents: 0c5b301
Author: Nick Couchman <vn...@apache.org>
Authored: Thu Feb 8 09:55:03 2018 -0500
Committer: Nick Couchman <vn...@apache.org>
Committed: Fri Feb 9 13:17:08 2018 -0500

----------------------------------------------------------------------
 .../servlet/GuacamoleHTTPTunnelServlet.java      | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/5aaea07b/guacamole-common/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
----------------------------------------------------------------------
diff --git 
a/guacamole-common/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
 
b/guacamole-common/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
index fdbfb8e..6195b39 100644
--- 
a/guacamole-common/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
+++ 
b/guacamole-common/src/main/java/org/apache/guacamole/servlet/GuacamoleHTTPTunnelServlet.java
@@ -149,26 +149,23 @@ public abstract class GuacamoleHTTPTunnelServlet extends 
HttpServlet {
      * @param response
      *     The HTTP response to use to send the error.
      *
-     * @param guacStatus
-     *     The status to send
-     *
-     * @param message
-     *     A human-readable message that can be presented to the user.
+     * @param guacamoleException
+     *     The exception that caused this error.
      *
      * @throws ServletException
      *     If an error prevents sending of the error code.
      */
     protected void sendError(HttpServletResponse response,
-            GuacamoleStatus guacStatus, String message)
+            GuacamoleException guacamoleException)
             throws ServletException {
 
         try {
 
             // If response not committed, send error code and message
             if (!response.isCommitted()) {
-                response.addHeader("Guacamole-Status-Code", 
Integer.toString(guacStatus.getGuacamoleStatusCode()));
-                response.addHeader("Guacamole-Error-Message", message);
-                response.sendError(guacStatus.getHttpStatusCode());
+                response.addHeader("Guacamole-Status-Code", 
Integer.toString(guacamoleException.getStatus().getGuacamoleStatusCode()));
+                response.addHeader("Guacamole-Error-Message", 
guacamoleException.getMessage());
+                response.sendError(guacamoleException.getHttpStatusCode());
             }
 
         }
@@ -258,12 +255,12 @@ public abstract class GuacamoleHTTPTunnelServlet extends 
HttpServlet {
         // HTTP response, logging each error appropriately.
         catch (GuacamoleClientException e) {
             logger.warn("HTTP tunnel request rejected: {}", e.getMessage());
-            sendError(response, e.getStatus(), e.getMessage());
+            sendError(response, e);
         }
         catch (GuacamoleException e) {
             logger.error("HTTP tunnel request failed: {}", e.getMessage());
             logger.debug("Internal error in HTTP tunnel.", e);
-            sendError(response, e.getStatus(), "Internal server error.");
+            sendError(response, e);
         }
 
     }

Reply via email to