struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15805] New: - Enhance ModuleException to allow getting chained Exceptions
Date Sun, 05 Jan 2003 06:45:07 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15805>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15805

Enhance ModuleException to allow getting chained Exceptions

           Summary: Enhance ModuleException to allow getting chained
                    Exceptions
           Product: Struts
           Version: Nightly Build
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Utilities
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: matt@raibledesigns.com


It'd be nice if it was possible to use a ModuleException to get a list of
chained exceptions and display them to the user.

I don't know how this would work, but using JDK 1.4, it might look something
like that below.  This doesn't compile, but hopefully you get the idea - or
maybe I can already do it with this?

public class GeneralException extends ModuleException {
    //~ Constructors ===========================================================

    /**
     * Construct a new instance of this exception
     */
    public GeneralException() {
        super("errors.general");
    }

    /**
     * Constructor for this exception that allows you to pass in an exception
     * with possible causes.
     *
     * @param e
     */
    public GeneralException(Exception e) {
        super("errors.detail", getChainedExceptions(e));
    }
    
    protected String getChainedExceptions(Exception e) {
        StringBuffer sb = new StringBuffer();

        if (e.getCause() == null) {
            sb.append(e.getMessage());
        } else {
            while (e.getCause() != null) {
                sb.append(e.getMessage());
                sb.append("\n");
                e = (Exception) e.getCause();
            }
        }
        return sb.toString();
    }
}

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message