cz.cuni.amis.utils.exception
Class PogamutException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by cz.cuni.amis.utils.exception.PogamutException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ComponentBusErrorException, ComponentException, ComponentFutureException, ListenerMethodParametersException, ListenersAlreadyRegisteredException, MapChangeException, MapChangeException, MissingConstructorException, MoreComponentsForClassException, MoreThanOneListenerLevelAnnotationException, NoComponentForClassException, PogamutCancellationException, PogamutInterruptedException, PogamutIOException, PogamutJMXException, PogamutTimeoutException, UCCStartException, UCCStartException, UT2004AStarPathTimeoutException, WorldEventFuture.WorldEventFutureException, WorldObjectFuture.WorldObjectFutureException

public class PogamutException
extends java.lang.RuntimeException

Ancestor of all exceptions of the Pogamut platform (except PogamutIOException and PogamutRuntimeException). It automatically logs the exception to the platform log of the respective agent were the exception occurred.

Note that Pogamut exceptions are storing the information whether they have been already logged + the instance of the object that has created (thrown) them.

Because of the 'origin' object you don't have to bother to prefix your exceptions with origin's name. All you have to care about is to have properly implemented toString() method of your objects so the messages looks pretty.

By design-choice, every PogamutException is RuntimeException - note that if exception is thrown you will probably just tore down everything or propagate it higher - no need to write throws to every method just because we want to state that something might throw an exception.

See Also:
Serialized Form

Constructor Summary
PogamutException(java.lang.String message, java.util.logging.Logger log, java.lang.Object origin)
          Constructs a new exception with the specified detail message.
PogamutException(java.lang.String message, java.lang.Object origin)
          Constructs a new exception with the specified detail message.
PogamutException(java.lang.String message, java.lang.Throwable cause)
          Constructs a new exception with the specified detail message.
PogamutException(java.lang.String message, java.lang.Throwable cause, java.util.logging.Logger log, java.lang.Object origin)
          Constructs a new exception with the specified detail message and cause.
PogamutException(java.lang.String message, java.lang.Throwable cause, java.lang.Object origin)
          Constructs a new exception with the specified detail message and cause.
PogamutException(java.lang.Throwable cause, java.util.logging.Logger log, java.lang.Object origin)
          Constructs a new exception with the specified detail message and cause.
PogamutException(java.lang.Throwable cause, java.lang.Object origin)
          Constructs exception based on the cause an origin.
 
Method Summary
 java.lang.Object getOrigin()
          Returns the object that has thrown the exception.
 boolean isLogged()
          Whether the exception has been logged to any logger.
 void logException(java.util.logging.Logger log)
          Logs the exception to the log + sets isLogged() to true.
 void logExceptionOnce(java.util.logging.Logger log)
          Logs the exception to the log iff !isLogged().
 void setLogged(boolean logged)
          Set whether the exception has been logged to the Platform logger, if not it will be logged as soon as it encounters some catch block from the Pogamut platform.
 java.lang.String toString()
          Serialize the exception to String.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PogamutException

public PogamutException(java.lang.Throwable cause,
                        java.lang.Object origin)
Constructs exception based on the cause an origin.

Parameters:
cause -
origin - may be null

PogamutException

public PogamutException(java.lang.String message,
                        java.lang.Object origin)
Constructs a new exception with the specified detail message.

Not logging anything anywhere on its own.

Parameters:
message -
origin - which object does produced the exception

PogamutException

public PogamutException(java.lang.String message,
                        java.lang.Throwable cause)
Constructs a new exception with the specified detail message.

Not logging anything anywhere on its own.

Parameters:
message -
cause -

PogamutException

public PogamutException(java.lang.String message,
                        java.lang.Throwable cause,
                        java.lang.Object origin)
Constructs a new exception with the specified detail message and cause.

Not logging anything anywhere on its own.

Parameters:
message -
cause -
origin - object that thrown the exception, may be null

PogamutException

public PogamutException(java.lang.String message,
                        java.util.logging.Logger log,
                        java.lang.Object origin)
Constructs a new exception with the specified detail message.

Logs the exception via specified Logger.

Parameters:
message -
origin - which object does produced the exception, may be null

PogamutException

public PogamutException(java.lang.Throwable cause,
                        java.util.logging.Logger log,
                        java.lang.Object origin)
Constructs a new exception with the specified detail message and cause.

Logs the exception via specified Logger.

Parameters:
message -
cause -
origin - object that thrown the exception

PogamutException

public PogamutException(java.lang.String message,
                        java.lang.Throwable cause,
                        java.util.logging.Logger log,
                        java.lang.Object origin)
Constructs a new exception with the specified detail message and cause.

Logs the exception via specified Logger.

Parameters:
message -
cause -
origin - object that thrown the exception, may be null
Method Detail

isLogged

public boolean isLogged()
Whether the exception has been logged to any logger.

Note that sometimes it's not possible to log the exception as it is created due to lack of the logger - therefore we propagate this information through the stack and as soon as it encounters some Pogamut-platform catch block it will be logged.

Returns:

setLogged

public void setLogged(boolean logged)
Set whether the exception has been logged to the Platform logger, if not it will be logged as soon as it encounters some catch block from the Pogamut platform.

Parameters:
logged -

getOrigin

public java.lang.Object getOrigin()
Returns the object that has thrown the exception.

Returns:

toString

public java.lang.String toString()
Serialize the exception to String.

Overrides:
toString in class java.lang.Throwable

logException

public void logException(java.util.logging.Logger log)
Logs the exception to the log + sets isLogged() to true.


logExceptionOnce

public void logExceptionOnce(java.util.logging.Logger log)
Logs the exception to the log iff !isLogged().

Logs the exception only once! Successive calls do nothing.