diff options
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSForwardException.java')
| -rw-r--r-- | projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSForwardException.java | 172 |
1 files changed, 76 insertions, 96 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSForwardException.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSForwardException.java index 1db0ad2..10f54af 100644 --- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSForwardException.java +++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSForwardException.java @@ -23,135 +23,115 @@ import java.io.PrintWriter; import java.io.StringWriter; /** -* Serves to wrap an exception inside of a RuntimeException, -* which is not required to be declared in a throws statement. -* -* @author michael@mpowers.net -* @author $Author: cgruber $ -* @version $Revision: 893 $ -*/ + * Serves to wrap an exception inside of a RuntimeException, which is not + * required to be declared in a throws statement. + * + * @author michael@mpowers.net + * @author $Author: cgruber $ + * @version $Revision: 893 $ + */ -public class NSForwardException extends RuntimeException -{ +public class NSForwardException extends RuntimeException { protected String message; protected Throwable wrappedThrowable; - + /** - * Default constructor. - */ - public NSForwardException() - { + * Default constructor. + */ + public NSForwardException() { super(); message = null; - wrappedThrowable = null; + wrappedThrowable = null; } - + /** - * Standard constructor with message. - */ - public NSForwardException( String aMessage ) - { - super( aMessage ); + * Standard constructor with message. + */ + public NSForwardException(String aMessage) { + super(aMessage); message = aMessage; wrappedThrowable = null; } - + /** - * Specifies a throwable to wrap. - */ - public NSForwardException( Throwable aThrowable ) - { + * Specifies a throwable to wrap. + */ + public NSForwardException(Throwable aThrowable) { super(); message = null; wrappedThrowable = aThrowable; } - + /** - * Specifies a message and a throwable to wrap. - */ - public NSForwardException( Throwable aThrowable, String aMessage ) - { - super( aMessage ); + * Specifies a message and a throwable to wrap. + */ + public NSForwardException(Throwable aThrowable, String aMessage) { + super(aMessage); message = aMessage; wrappedThrowable = aThrowable; } - - /** - * Returns the wrapped throwable. - */ - public Throwable originalException() - { - return wrappedThrowable; - } - - public void printStackTrace(PrintWriter s) - { - if ( message != null ) - { - s.println( toString() ); + + /** + * Returns the wrapped throwable. + */ + public Throwable originalException() { + return wrappedThrowable; + } + + public void printStackTrace(PrintWriter s) { + if (message != null) { + s.println(toString()); } - if ( wrappedThrowable != null ) - { - wrappedThrowable.printStackTrace( s ); + if (wrappedThrowable != null) { + wrappedThrowable.printStackTrace(s); return; } - super.printStackTrace( s ); + super.printStackTrace(s); } - - public void printStackTrace(PrintStream s) - { - if ( message != null ) - { - s.println( toString() ); + + public void printStackTrace(PrintStream s) { + if (message != null) { + s.println(toString()); } - if ( wrappedThrowable != null ) - { - wrappedThrowable.printStackTrace( s ); + if (wrappedThrowable != null) { + wrappedThrowable.printStackTrace(s); return; } - super.printStackTrace( s ); + super.printStackTrace(s); } - - public void printStackTrace() - { - if ( message != null ) - { - System.err.println( toString() ); + + public void printStackTrace() { + if (message != null) { + System.err.println(toString()); } - if ( wrappedThrowable != null ) - { - wrappedThrowable.printStackTrace(); + if (wrappedThrowable != null) { + wrappedThrowable.printStackTrace(); return; } super.printStackTrace(); } - - public String stackTrace() - { - StringWriter writer = new StringWriter(); - PrintWriter printWriter = new PrintWriter( writer ); - if ( wrappedThrowable != null ) - { - wrappedThrowable.printStackTrace( printWriter ); + + public String stackTrace() { + StringWriter writer = new StringWriter(); + PrintWriter printWriter = new PrintWriter(writer); + if (wrappedThrowable != null) { + wrappedThrowable.printStackTrace(printWriter); + } else { + super.printStackTrace(printWriter); } - else - { - super.printStackTrace( printWriter ); - } - printWriter.flush(); - printWriter.close(); - return writer.toString(); - } - - public String toString() - { - String result = message; - if ( result == null ) result = ""; - if ( wrappedThrowable != null ) - { - result = wrappedThrowable.toString() + " : " + result; + printWriter.flush(); + printWriter.close(); + return writer.toString(); + } + + public String toString() { + String result = message; + if (result == null) + result = ""; + if (wrappedThrowable != null) { + result = wrappedThrowable.toString() + " : " + result; } - return result; - } - + return result; + } + } |
