@Nullable
    private APIPatchError createPatchFailure(
            @Nonnull APIPatch.Operation op, @Nullable String identifier,
            @Nonnull String path, @Nonnull Throwable t) {

        /*
         * If the failure is a translatable type, use the translation directly
         * in the patch error.
         */
        if (t instanceof Translatable)
            return new APIPatchError(
                op, identifier, path,
                ((Translatable) t).getTranslatableMessage());

        /*
         * If the failure represents a known Guacamole exception but is not
         * translateable, create a patch error containing the raw untranslated
         * exception message.
         */
        if (t instanceof GuacamoleException) {

            // Create a translated message that will fall
            // through to the untranslated message
            TranslatableMessage message = new TranslatableMessage(
                    "APP.TEXT_UNTRANSLATED", Collections.singletonMap(
                            "MESSAGE", ((GuacamoleException) t).getMessage()));

            return new APIPatchError(op, identifier, path, message);
        }

        // The error is not a known type - no patch error can be generated
        return null;
    }
If the provided throwable is a known Guacamole-specific type, create and
return a APIPatchError with an error message extracted from the error.
If the provided throwable is not a known type, null will be returned.

@param op
    The operation being attempted when the error occurred.

@param identifier
    The identifier of the object in question, if any.

@param path
    The path for the patch that was being applied when the error occurred.

@param t
    The error that occurred while attempting to apply the patch.

@return
    A APIPatchError with an error message extracted from the provided
    throwable - if it's a known type, otherwise null.
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java