Redid nestable exceptions using standard Java support for same rather than

Jakarta lang's support. No longer do we depend on Jakarta lang.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1068 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2003-03-17 23:01:37 +00:00
parent 6815e27ea1
commit 400b61e34a
3 changed files with 16 additions and 139 deletions
@@ -1,5 +1,5 @@
// //
// $Id: NestableIOException.java,v 1.2 2002/04/01 01:57:03 mdb Exp $ // $Id: NestableIOException.java,v 1.3 2003/03/17 23:01:37 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -24,37 +24,12 @@ import java.io.PrintStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.IOException; import java.io.IOException;
import org.apache.commons.lang.exception.Nestable;
import org.apache.commons.lang.exception.NestableDelegate;
/** /**
* A base class for IO exceptions that can contain other exceptions. * A convenience class for creating IO exceptions that are caused by other
* * exceptions.
* @see org.apache.commons.lang.exception.NestableException
*/ */
public class NestableIOException public class NestableIOException extends IOException
extends IOException
implements Nestable
{ {
/**
* Constructs a new <code>NestableIOException</code> without specified
* detail message.
*/
public NestableIOException ()
{
}
/**
* Constructs a new <code>NestableIOException</code> with specified
* detail message.
*
* @param msg the error message.
*/
public NestableIOException (String msg)
{
super(msg);
}
/** /**
* Constructs a new <code>NestableIOException</code> with specified * Constructs a new <code>NestableIOException</code> with specified
* nested <code>Throwable</code>. * nested <code>Throwable</code>.
@@ -64,8 +39,7 @@ public class NestableIOException
*/ */
public NestableIOException (Throwable cause) public NestableIOException (Throwable cause)
{ {
super(); initCause(cause);
_cause = cause;
} }
/** /**
@@ -79,101 +53,6 @@ public class NestableIOException
public NestableIOException (String msg, Throwable cause) public NestableIOException (String msg, Throwable cause)
{ {
super(msg); super(msg);
_cause = cause; initCause(cause);
} }
/**
* Returns the nested exception.
*
* @see Nestable#getCause
*/
public Throwable getCause ()
{
return _cause;
}
/**
* Concatenates this exception's message with that of the nested
* exception and returns it.
*
* @see Nestable#getMessage
*/
public String getMessage ()
{
StringBuffer msg = new StringBuffer();
String ourMsg = super.getMessage();
// add our message (if there is one)
if (ourMsg != null) {
msg.append(ourMsg);
}
// add our cause's message (if there is one)
if (_cause != null) {
String causeMsg = _cause.getMessage();
if (causeMsg != null) {
if (ourMsg != null) {
msg.append(": ");
}
msg.append(causeMsg);
}
}
return (msg.length() > 0 ? msg.toString() : null);
}
/**
* Prints the stack trace of this exception (and the nested exception)
* the the standard error stream.
*
* @see Nestable#printStackTrace()
*/
public void printStackTrace ()
{
_delegate.printStackTrace();
}
/**
* Prints the stack trace of this exception (and the nested exception)
* to the specified print stream.
*
* @param out <code>PrintStream</code> to use for output.
*
* @see Nestable#printStackTrace(PrintStream)
*/
public void printStackTrace (PrintStream out)
{
_delegate.printStackTrace(out);
}
/**
* Prints the stack trace of this exception (and the nested exception)
* to the specified print writer.
*
* @param out <code>PrintWriter</code> to use for output.
*
* @see Nestable#printStackTrace(PrintWriter)
*/
public void printStackTrace (PrintWriter out)
{
_delegate.printStackTrace(out);
}
/**
* Prints the stack trace only of the enclosing exception.
*
* @see Nestable#printPartialStackTrace(PrintWriter)
*/
public final void printPartialStackTrace (PrintWriter out)
{
super.printStackTrace(out);
}
/** The helper instance which contains much of the code to which we
* delegate. */
protected NestableDelegate _delegate = new NestableDelegate(this);
/** Holds the reference to the exception or error that caused this
* exception to be thrown. */
protected Throwable _cause = null;
} }
@@ -1,5 +1,5 @@
// //
// $Id: PersistenceException.java,v 1.3 2002/04/01 01:57:03 mdb Exp $ // $Id: PersistenceException.java,v 1.4 2003/03/17 23:01:37 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -20,8 +20,6 @@
package com.samskivert.io; package com.samskivert.io;
import org.apache.commons.lang.exception.NestableException;
/** /**
* A persistence exception can be thrown when an error occurs in * A persistence exception can be thrown when an error occurs in
* underlying persistence code. By encapsulating errors, one retains the * underlying persistence code. By encapsulating errors, one retains the
@@ -29,7 +27,7 @@ import org.apache.commons.lang.exception.NestableException;
* affecting the interface to persistence services presented to the * affecting the interface to persistence services presented to the
* application. * application.
*/ */
public class PersistenceException extends NestableException public class PersistenceException extends Exception
{ {
/** /**
* Constructs a persistence exception with the specified error * Constructs a persistence exception with the specified error
@@ -46,7 +44,8 @@ public class PersistenceException extends NestableException
*/ */
public PersistenceException (String message, Exception cause) public PersistenceException (String message, Exception cause)
{ {
super(message, cause); super(message);
initCause(cause);
} }
/** /**
@@ -55,6 +54,6 @@ public class PersistenceException extends NestableException
*/ */
public PersistenceException (Exception cause) public PersistenceException (Exception cause)
{ {
super(cause); initCause(cause);
} }
} }
@@ -1,5 +1,5 @@
// //
// $Id: ServiceUnavailableException.java,v 1.2 2002/04/01 01:57:03 mdb Exp $ // $Id: ServiceUnavailableException.java,v 1.3 2003/03/17 23:01:37 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -20,8 +20,6 @@
package com.samskivert.util; package com.samskivert.util;
import org.apache.commons.lang.exception.NestableRuntimeException;
/** /**
* The service unavailable exception can be thrown by any service that * The service unavailable exception can be thrown by any service that
* relies on some other services which is currently not available. If a * relies on some other services which is currently not available. If a
@@ -36,7 +34,7 @@ import org.apache.commons.lang.exception.NestableRuntimeException;
* class of error recovery as if our service threw a * class of error recovery as if our service threw a
* <code>NullPointerException</code>). * <code>NullPointerException</code>).
*/ */
public class ServiceUnavailableException extends NestableRuntimeException public class ServiceUnavailableException extends RuntimeException
{ {
/** /**
* Constructs a service unavailable exception with the specified error * Constructs a service unavailable exception with the specified error
@@ -53,7 +51,8 @@ public class ServiceUnavailableException extends NestableRuntimeException
*/ */
public ServiceUnavailableException (String message, Exception cause) public ServiceUnavailableException (String message, Exception cause)
{ {
super(message, cause); super(message);
initCause(cause);
} }
/** /**
@@ -62,6 +61,6 @@ public class ServiceUnavailableException extends NestableRuntimeException
*/ */
public ServiceUnavailableException (Exception cause) public ServiceUnavailableException (Exception cause)
{ {
super(cause); initCause(cause);
} }
} }