Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory usw-pr-cvs1:/tmp/cvs-serv3300/src/org/beepcore/beep/core
Modified Files:
BEEPException.java
Log Message:
added basic exception chaining
Index: BEEPException.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/BEEPException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** BEEPException.java 2001/11/08 05:51:34 1.2
--- BEEPException.java 2001/12/16 01:02:13 1.3
***************
*** 1,7 ****
-
/*
! * BEEPException.java $Revision$ $Date$
*
! * Copyright (c) 2001 Invisible Worlds, Inc. All rights reserved.
*
* The contents of this file are subject to the Blocks Public License (the
--- 1,6 ----
/*
! * BEEPException.java $Revision$ $Date$
*
! * Copyright (c) 2001 Huston Franklin. All rights reserved.
*
* The contents of this file are subject to the Blocks Public License (the
***************
*** 20,45 ****
/**
! * A subclass of java.lang.Exception that we provide so users of the
! * library can differentiate between BEEP exceptions, and JVM exceptions.
! *
*
- * @author Eric Dixon
* @author Huston Franklin
! * @author Jay Kint
! * @author Scott Pead
! * @version $Revision, $Date$
*/
public class BEEPException extends Exception {
/**
! * Constructor BEEPException
*
! *
! * @param s
*
*/
! public BEEPException(String s)
! {
! super(s);
}
}
--- 19,124 ----
/**
! * An exception for representing BEEP related errors.
! * <code>BEEPException</code> adds support for exception chaining
! * similar to what is available in JDK 1.4.
*
* @author Huston Franklin
! * @version $Revision$, $Date$
*/
public class BEEPException extends Exception {
+ private final Throwable cause;
+
/**
! * Constructs a new <code>BEEPException</code> with the specified
! * detail message.
*
! * @param message the detailed message which is saved for later
! * retrieval by the <code>getMessage()</code> method.
! */
! public BEEPException(String message) {
! super(message);
! cause = null;
! }
!
! /**
! * Constructs a new <code>BEEPException</code> with the specified
! * cause and a detailed message of
! * <code>(cause == null ? null : cause.toString())</code>.
*
+ * @param cause the cause which is saved for later retrieval by
+ * the <code>getCause()</code> method.
+ */
+ public BEEPException(Throwable cause) {
+ super(cause == null ? null : cause.toString());
+ this.cause = cause;
+ }
+
+ /*
+ * requests to fill in the stack trace we will have to ignore.
+ * We can't throw an exception here, because this method is
+ * called by the constructor of Throwable
+ */
+ public Throwable fillInStackTrace() {
+ return this;
+ }
+
+ /**
+ * Returns the cause of this <code>BEEPException</code>.
*/
! public Throwable getCause() {
! return cause;
! }
!
! public String getLocalizedMessage() {
! if (cause == null) {
! return super.getLocalizedMessage();
! }
! return cause.getLocalizedMessage();
! }
!
! /**
! * Prints this <code>BEEPException</code> and its backtrace to the
! * standard error stream. If this <code>BEEPException</code> was
! * initialized with a <code>Throwable</code> the backtrace for it
! * will be printed as well.
! */
! public void printStackTrace() {
! printStackTrace(System.err);
! }
!
! /**
! * Prints this <code>BEEPException</code> and its backtrace to the
! * specified print stream.
! */
! public void printStackTrace(java.io.PrintStream s) {
! synchronized (s) {
! super.printStackTrace(s);
! if (cause != null) {
! s.print("Caused by: ");
! cause.printStackTrace(s);
! }
! }
! }
!
! /**
! * Prints this <code>BEEPException</code> and its backtrace to the
! * specified print writer.
! */
! public void printStackTrace(java.io.PrintWriter s) {
! synchronized (s) {
! super.printStackTrace(s);
! if (cause != null) {
! s.print("Caused by: ");
! cause.printStackTrace(s);
! }
! }
! }
!
! public String toString() {
! if (cause == null) {
! return super.toString();
! }
! return super.toString() + cause.toString();
}
}
|