public class PogamutException extends RuntimeException
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.
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
public PogamutException(Throwable cause, Object origin)
cause
- origin
- may be nullpublic PogamutException(String message, Object origin)
Not logging anything anywhere on its own.
message
- origin
- which object does produced the exceptionpublic PogamutException(String message, Throwable cause)
Not logging anything anywhere on its own.
message
- cause
- public PogamutException(String message, Throwable cause, Object origin)
Not logging anything anywhere on its own.
message
- cause
- origin
- object that thrown the exception, may be nullpublic PogamutException(String message, Logger log, Object origin)
Logs the exception via specified Logger.
message
- origin
- which object does produced the exception, may be nullpublic PogamutException(Throwable cause, Logger log, Object origin)
Logs the exception via specified Logger.
message
- cause
- origin
- object that thrown the exceptionpublic boolean isLogged()
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.
public void setLogged(boolean logged)
logged
- public Object getOrigin()
public String toString()
public void logException(Logger log)
public void logExceptionOnce(Logger log)
Logs the exception only once! Successive calls do nothing.
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.