private static void handleReceivedError(GuacamoleInstruction instruction)
            throws GuacamoleException {

        // Provide reasonable default error message for invalid "error"
        // instructions that fail to provide one
        String message = "Internal error within guacd / protocol handling.";

        // Consider all error instructions without a corresponding status code
        // to be server errors
        GuacamoleStatus status = GuacamoleStatus.SERVER_ERROR;

        // Parse human-readable message from "error" instruction, warning if no
        // message was given
        List<String> args = instruction.getArgs();
        if (args.size() >= 1)
            message = args.get(0);
        else
            logger.debug("Received \"error\" instruction with no corresponding message.");

        // Parse the status code from the received error instruction, warning
        // if the status code is missing or invalid
        if (args.size() >= 2) {
            try {
                
                // Translate numeric status code into a GuacamoleStatus
                int statusCode = Integer.parseInt(args.get(1));
                GuacamoleStatus parsedStatus = GuacamoleStatus.fromGuacamoleStatusCode(statusCode);
                if (parsedStatus != null)
                    status = parsedStatus;
                else
                    logger.debug("Received \"error\" instruction with unknown/invalid status code: {}", statusCode);

            }
            catch (NumberFormatException e) {
                logger.debug("Received \"error\" instruction with non-numeric status code.", e);
            }
        }
        else
            logger.debug("Received \"error\" instruction without status code.");

        // Convert parsed status code and message to a GuacamoleException
        throw status.toException(message);

    }
Parses the given "error" instruction, throwing a GuacamoleException that
corresponds to its status code and message.

@param instruction
    The "error" instruction to parse.

@throws GuacamoleException
    A GuacamoleException that corresponds to the status code and message
    present within the given "error" instruction.
guacamole-common/src/main/java/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.java