package edu.neu.ccs.demeter.dj; import java.io.*; /** Thrown by {@link Visitor#invokeMethod(String, Object, Class)} when a visitor method throws an exception. */ public class VisitorMethodException extends RuntimeException { /** The exception thrown by the visitor method. */ private Throwable exception; /** Construct a VisitorMethodException wrapper around the exception thrown by the visitor method. */ public VisitorMethodException(Throwable exception) { super(); this.exception = exception; } /** Get the exception thrown by the visitor method. */ public Throwable getException() { return exception; } /** Prints the stack trace of the exception thrown by the visitor method in place of this one, to stderr. */ public void printStackTrace() { printStackTrace(System.err); } /** Print the stack trace of the exception thrown by the visitor method in place of this one. */ public void printStackTrace(PrintStream ps) { ps.print("edu.neu.ccs.demeter.dj.VisitorMethodException: "); exception.printStackTrace(ps); } /** Print the stack trace of the exception thrown by the visitor method in place of this one. */ public void printStackTrace(PrintWriter pw) { pw.print("edu.neu.ccs.demeter.dj.VisitorMethodException: "); exception.printStackTrace(pw); } }