sim.util.CausedRuntimeException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mason Show documentation
Show all versions of mason Show documentation
MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.
The newest version!
package sim.util;
import java.io.*;
/**
A simple RuntimeException which wraps a deeper exception inside of it and
prints it in a fashion similar to exceptions like InvocationTargetException.
This exception is largely obviated by the 'cause' mechanism in Java 1.4
Throwables -- but Java 1.3 doesn't have it and thus we need it.
*/
public class CausedRuntimeException extends RuntimeException
{
private Throwable target;
String message;
protected CausedRuntimeException() { /* Not allowed */ }
public CausedRuntimeException(Throwable target)
{
super();
this.target = target;
message = "";
}
public CausedRuntimeException(Throwable target, String message)
{
super(message);
this.target = target;
this.message = message;
}
public void printStackTrace(PrintStream stream)
{
if (target == null) // duh, need to print our own stack trace
super.printStackTrace();
else
stream.println("CausedRuntimeException: " + message);
stream.println("Caused By:");
target.printStackTrace(stream);
}
public void printStackTrace(PrintWriter stream)
{
if (target == null) // duh, need to print our own stack trace
super.printStackTrace();
else
stream.println("CausedRuntimeException: " + message);
stream.println("Caused By:");
target.printStackTrace(stream);
}
public void printStackTrace() { printStackTrace(System.err); }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy