cz.cuni.amis.utils.exception
Class PogamutException

Package class diagram package 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:
Serializable
Direct Known Subclasses:
PogamutCancellationException, PogamutInterruptedException, PogamutIOException, PogamutJMXException, PogamutTimeoutException

public class PogamutException
extends 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.

Author:
Jimmy
See Also:
Serialized Form

Constructor Summary
PogamutException(String message, Logger log, Object origin)
          Constructs a new exception with the specified detail message.
PogamutException(String message, Object origin)
          Constructs a new exception with the specified detail message.
PogamutException(String message, Throwable cause)
          Constructs a new exception with the specified detail message.
PogamutException(String message, Throwable cause, Logger log, Object origin)
          Constructs a new exception with the specified detail message and cause.
PogamutException(String message, Throwable cause, Object origin)
          Constructs a new exception with the specified detail message and cause.
PogamutException(Throwable cause, Logger log, Object origin)
          Constructs a new exception with the specified detail message and cause.
PogamutException(Throwable cause, Object origin)
          Constructs exception based on the cause an origin.
 
Method Summary
 Object getOrigin()
          Returns the object that has thrown the exception.
 boolean isLogged()
          Whether the exception has been logged to any logger.
 void logException(Logger log)
          Logs the exception to the log + sets isLogged() to true.
 void logExceptionOnce(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.
 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(Throwable cause,
                        Object origin)
Constructs exception based on the cause an origin.

Parameters:
cause -
origin - may be null

PogamutException

public PogamutException(String message,
                        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(String message,
                        Throwable cause)
Constructs a new exception with the specified detail message.

Not logging anything anywhere on its own.

Parameters:
message -
cause -

PogamutException

public PogamutException(String message,
                        Throwable cause,
                        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(String message,
                        Logger log,
                        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(Throwable cause,
                        Logger log,
                        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(String message,
                        Throwable cause,
                        Logger log,
                        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 Object getOrigin()
Returns the object that has thrown the exception.

Returns:

toString

public String toString()
Serialize the exception to String.

Overrides:
toString in class Throwable

logException

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


logExceptionOnce

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

Logs the exception only once! Successive calls do nothing.



Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.