|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Throwable java.lang.Exception java.lang.RuntimeException cz.cuni.amis.utils.exception.PogamutException
public class PogamutException
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.
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 |
---|
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 PogamutException(String message, Throwable cause, Logger log, Object origin)
Logs the exception via specified Logger.
message
- cause
- origin
- object that thrown the exception, may be nullMethod Detail |
---|
public 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()
toString
in class Throwable
public void logException(Logger log)
public void logExceptionOnce(Logger log)
Logs the exception only once! Successive calls do nothing.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |