base/struts-tools/src/main/com/thesett/common/webapp/actions/ErrorHandler.java
public static void handleErrors(Throwable exception, ActionErrors errors)
    {
        // Log the error.
        log.log(Level.SEVERE, exception.getMessage(), exception);

        if (exception.getCause() == null)
        {
            log.fine("Exception.getCause() is null");
        }

        // Unwrap the exception if it is a WrappedStrutsServletException, which is a place holder for returning
        // other throwables from struts actions.
        // See BaseAction and WrappedStrutsServletException for more information.
        if ((exception instanceof WrappedStrutsServletException) && (exception.getCause() != null))
        {
            exception = exception.getCause();
            log.fine("Unwrapped WrappedStrutsServletException");
        }

        // Create an error called 'exception' in the Struts errors for debugging purposes
        // Debugging code can print this piece of html containing the exception stack trace at the bottom
        // of the page for convenience.
        Writer stackTrace = new StringWriter();

        exception.printStackTrace(new PrintWriter(new HTMLFilter(stackTrace)));
        errors.add("exception", new ActionError("error.general", stackTrace));

        // Check if the exception is a user readable exception
        if (exception instanceof UserReadableError)
        {
            UserReadableError userError = (UserReadableError) exception;

            // Check that it contains a user readable message
            if (userError.isUserReadable())
            {
                // Check if there is an error message key to use
                if (userError.getUserMessageKey() != null)
                {
                    errors.add("generalerror",
                        new ActionError(userError.getUserMessageKey(), userError.getUserMessageKey()));
                }

                // There is no error message key to use so default to error.general and pass the error message as an
                // argument so that it will be displayed
                else
                {
                    errors.add("generalerror", new ActionError("error.general", userError.getUserMessage()));
                }

                return;
            }
        }

        // Not a user reable exception so print a standard error message
        errors.add("generalerror", new ActionError("error.internalerror"));
    }
public static void handleErrors(Throwable exception, ActionErrors errors)
    {
        // Log the error.
        log.log(Level.SEVERE, exception.getMessage(), exception);

        if (exception.getCause() == null)
        {
            log.fine("Exception.getCause() is null");
        }

        // Unwrap the exception if it is a WrappedStrutsServletException, which is a place holder for returning
        // other throwables from struts actions.
        // See BaseAction and WrappedStrutsServletException for more information.
        if ((exception instanceof WrappedStrutsServletException) && (exception.getCause() != null))
        {
            exception = exception.getCause();
            log.fine("Unwrapped WrappedStrutsServletException");
        }

        // Create an error called 'exception' in the Struts errors for debugging purposes
        // Debugging code can print this piece of html containing the exception stack trace at the bottom
        // of the page for convenience.
        Writer stackTrace = new StringWriter();

        exception.printStackTrace(new PrintWriter(new HTMLFilter(stackTrace)));
        errors.add("exception", new ActionError("error.general", stackTrace));

        // Check if the exception is a user readable exception
        if (exception instanceof UserReadableError)
        {
            UserReadableError userError = (UserReadableError) exception;

            // Check that it contains a user readable message
            if (userError.isUserReadable())
            {
                // Check if there is an error message key to use
                if (userError.getUserMessageKey() != null)
                {
                    errors.add("generalerror",
                        new ActionError(userError.getUserMessageKey(), userError.getUserMessageKey()));
                }

                // There is no error message key to use so default to error.general and pass the error message as an
                // argument so that it will be displayed
                else
                {
                    errors.add("generalerror", new ActionError("error.general", userError.getUserMessage()));
                }

                return;
            }
        }

        // Not a user reable exception so print a standard error message
        errors.add("generalerror", new ActionError("error.internalerror"));
    }
Converts an exception into struts action errors. The exception stack trace is stored under the 'exception'
message key. The message resource 'error.internalerror' is stored under the message key 'generalerror'. The stack
trace is pretty printed in HTML.

@param exception The exception to be converted into struts action errors.
@param errors    The struts action errors object into which the action errors should be placed.

@todo  This method can be modified to check if the exception is a user readable exception and to insert the user
readable message under the 'generalerror' message key. Currently it does not handle user readable errors
like this.