org.ogf.saga.error
Class SagaException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.ogf.saga.error.SagaException
All Implemented Interfaces:
Serializable, Comparable<SagaException>, Iterable<SagaException>
Direct Known Subclasses:
AlreadyExistsException, AuthenticationFailedException, AuthorizationFailedException, BadParameterException, DoesNotExistException, IncorrectStateException, IncorrectURLException, NoSuccessException, NotImplementedException, PermissionDeniedException, SagaIOException, TimeoutException

public abstract class SagaException
extends Exception
implements Comparable<SagaException>, Iterable<SagaException>

This is the base class for all exceptions in SAGA. It is a checked exception, so all exceptions in SAGA are checked exceptions. The Throwable.getMessage() method does not quite behave as specified in the SAGA specs, because Java already has toString() for exactly that behavior. So, Throwable.getMessage() does what it always does for Java throwables.

A simple mechanism exists for storing and examining exceptions that may be thrown by adaptors in adaptor-based Saga implementations. In such implementations, the top-level exception (the one highest up in the Saga exception hierarchy) is not always the most informative one, and the implementation is not always capable of selecting the most informative exception. In these cases, the implementation may opt to add the individual exceptions as nested exceptions to the exception thrown. The nested exceptions can be examined using the getAllExceptions() or getAllMessages() methods.

In addition to the getAllExceptions() and getAllMessages() mechanisms, this implementation also allows the user to iterate over the lower-level exception list.

See Also:
Serialized Form

Method Summary
 void addNestedException(SagaException e)
          Adds an exception to the list of nested exceptions.
 int compareTo(SagaException o)
          Gives preference to the most specific exception.
 List<SagaException> getAllExceptions()
          Gets the list of lower-level exceptions.
 List<String> getAllMessages()
          Gets the list of lower-level exception messages.
 SagaObject getObject()
          Returns the SAGA object associated with this exception.
 Iterator<SagaException> iterator()
          Returns an iterator that iterates over the nested exceptions.
 String toString()
          Returns a short description of this SagaException.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getObject

public SagaObject getObject()
                     throws DoesNotExistException,
                            NoSuccessException
Returns the SAGA object associated with this exception.

Returns:
the associated SAGA object.
Throws:
DoesNotExistException - is thrown when there is no object associated with this exception.
NoSuccessException - is thrown when the operation was not successfully performed, and none of the other exceptions apply.

compareTo

public int compareTo(SagaException o)
Gives preference to the most specific exception. This implements the ordering as in the SAGA specs. Returns < 0 if this exception is more specific than the specified exception, 0 if equal, and > 0 if less.

Specified by:
compareTo in interface Comparable<SagaException>

toString

public String toString()
Returns a short description of this SagaException. If this SagaException object was created with a non-null detail message string, then the result is the concatenation of three strings: If this SagaException object was created with a null detail message string, then only the simple (unqualified) name of the actual class of this object is returned.

Overrides:
toString in class Throwable
Returns:
a string representation of this SagaException.

addNestedException

public void addNestedException(SagaException e)
Adds an exception to the list of nested exceptions. This method should only be used by SAGA implementations.

Parameters:
e - the exception to be added to the list.

iterator

public Iterator<SagaException> iterator()
Returns an iterator that iterates over the nested exceptions.

Specified by:
iterator in interface Iterable<SagaException>
Returns:
the iterator.

getAllExceptions

public List<SagaException> getAllExceptions()
Gets the list of lower-level exceptions. The first exception in the list is the one on which this method is invoked, but without lower-level exceptions.

Returns:
the list of exceptions.

getAllMessages

public List<String> getAllMessages()
Gets the list of lower-level exception messages. The first message in the list is from the one on which this method is invoked.

Returns:
the list of exception messages.


The SAGA Java language bindings, version-1.1.1