NestedException.java :  » Aspect-oriented » dynaop » dynaop » util » Java Open Source

Java Open Source » Aspect oriented » dynaop 
dynaop » dynaop » util » NestedException.java
package dynaop.util;

import java.io.*;

/**
 * Turns a nested exception into a runtime exception.
 *
 * @author Bob Lee (crazybob@crazybob.org)
 */
public class NestedException extends RuntimeException {

    /** Wrap another exeception in a RuntimeException. */
    public static RuntimeException wrap(Throwable t) {
        if (t instanceof RuntimeException) return (RuntimeException) t;
        return new NestedException(t);
    }

    Throwable throwable;

    /** Wraps another exeception. */
    NestedException(Throwable t) {
        super();
    this.throwable = t;
    }

    public String toString() {
        return this.getMessage();
    }

    public String getMessage() {
        return this.throwable.getMessage();
    }

    public void printStackTrace() {
        this.throwable.printStackTrace();
    }

    public void printStackTrace(PrintStream out) {
        this.throwable.printStackTrace(out);
    }

    public void printStackTrace(PrintWriter out) {
    this.throwable.printStackTrace(out);
    }

  public Throwable getNested() {
    return throwable;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.