JCircusException.java 1.48 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
package jcircus.exceptions;

import java.io.*;

/**
* A generic application exception, compatible with Java versions prior
* to 1.4.
*
* This code has been released into the public domain and may be used
* for any purposes whatsoever without acknowledgment.
*
* @author Malcolm Sparks
*/
public class JCircusException extends Exception {
Throwable cause;
public JCircusException(String msg) {
super(msg);
}
public JCircusException(String msg, Throwable cause) {
super(msg);
this.cause = cause;
}
public Throwable getCause() {
return this.cause;
}
public void printStackTrace() {
super.printStackTrace();
if (this.cause != null) {
System.out.println("Caused by:");
this.cause.printStackTrace();
}
}
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
if (this.cause != null) {
s.println("Caused by:");
this.cause.printStackTrace(s);
}
}
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
if (this.cause != null) {
s.println("Caused by:");
this.cause.printStackTrace(s);
}
}
public String getMessage() {
if (this.cause == null) {
return super.getMessage();
} else {
return super.getMessage() + " (see below for lower-level details)";
}
}
}