de.smartics.exceptions
Class AbstractCoreException

Package class diagram package AbstractCoreException
java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by de.smartics.exceptions.AbstractCoreException
All Implemented Interfaces:
CoreException, Serializable
Direct Known Subclasses:
AbstractLocalizedException

public abstract class AbstractCoreException
     
     
extends Exception
implements CoreException

The base implementation of the core exception that supports unique identifying and exception codes for checked exceptions.

Author:
Robert Reiner
See Also:
Serialized Form

Field Summary
protected  de.smartics.exceptions.ExceptionInfo info
          Reference to common exception information.
 
Constructor Summary
protected AbstractCoreException(Code code)
          Constructor.
protected AbstractCoreException(String message, Code code)
          Constructor.
protected AbstractCoreException(String message, Throwable cause, Code code)
          Constructor.
protected AbstractCoreException(Throwable cause, Code code)
          Constructor.
 
Method Summary
 Throwable getCause()
          Returns the cause of this throwable or null if the cause is nonexistent or unknown.
 Code getCode()
          Returns the error or exception code of the exception.
 ExceptionId<?> getId()
          Returns the unique identifier of the exception.
 Date getTime()
          Returns the time the exception has been raised.
 String toString()
          Returns the string representation of the object for debugging.
 void truncateCause()
          Truncates the cause from the exception dependent on the ThrowableHandleMode set to the thread-local context.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, 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
 
Methods inherited from interface de.smartics.exceptions.CoreException
getLocalizedMessage, getMessage, getStackTrace, setStackTrace
 

Field Detail

info

protected final de.smartics.exceptions.ExceptionInfo info
Reference to common exception information. Currently this is the exception identifier and the exception code.

Constructor Detail

AbstractCoreException

protected AbstractCoreException(Code code)
Constructor.

Parameters:
code - the error or exception code of the exception.
See Also:
AbstractCoreException(String, Throwable, Code)

AbstractCoreException

protected AbstractCoreException(String message,
                                Code code)
Constructor.

Parameters:
message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method). Only used if there is no localized message in the bundle.
code - the error or exception code of the exception.
See Also:
AbstractCoreException(String, Throwable, Code)

AbstractCoreException

protected AbstractCoreException(Throwable cause,
                                Code code)
Constructor.

Parameters:
cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
code - the error or exception code of the exception.
See Also:
AbstractCoreException(String, Throwable, Code)

AbstractCoreException

protected AbstractCoreException(String message,
                                Throwable cause,
                                Code code)
                         throws NullPointerException
Constructor.

Parameters:
message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method). Only used if there is no localized message in the bundle.
cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
code - the error or exception code of the exception.
Throws:
NullPointerException - if the code is null.
See Also:
Exception.Exception(java.lang.String,java.lang.Throwable)
Method Detail

getId

public ExceptionId<?> getId()
Returns the unique identifier of the exception. The identifier is used to track an exception in different tiers.

This identifier must never be null.

Specified by:
getId in interface CoreException
Returns:
the unique identifier of the exception.
See Also:
CoreException.getId()

getCode

public Code getCode()
Returns the error or exception code of the exception.

This code must never be null.

Specified by:
getCode in interface CoreException
Returns:
the error or exception code of the exception.
See Also:
CoreException.getCode()

getTime

public Date getTime()
Returns the time the exception has been raised. The time instance is created and stored as soon as the exception is constructed.

Specified by:
getTime in interface CoreException
Returns:
the time the exception has been raised.
See Also:
CoreException.getTime()

getCause

public Throwable getCause()
Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is the throwable that caused this throwable to get thrown.)

This implementation returns the cause that was supplied via one of the constructors requiring a Throwable. While it is typically unnecessary to override this method, a subclass can override it to return a cause set by some other means. This is appropriate for a "legacy chained throwable" that predates the addition of chained exceptions to Throwable. Note that it is not necessary to override any of the PrintStackTrace methods, all of which invoke the getCause method to determine the cause of a throwable.

Specified by:
getCause in interface CoreException
Overrides:
getCause in class Throwable
Returns:
the cause of this throwable or null if the cause is nonexistent or unknown.
See Also:
Throwable.getCause()

truncateCause

public void truncateCause()
Truncates the cause from the exception dependent on the ThrowableHandleMode set to the thread-local context. After running this method the cause will be truncate and the full stack trace will no longer be available.

Specified by:
truncateCause in interface CoreException
See Also:
CoreException.truncateCause()

toString

public String toString()
Returns the string representation of the object for debugging.

Overrides:
toString in class Throwable
Returns:
the string representation of the object.


Copyright © 2007-null Kronseder & Reiner GmbH - smartics. All Rights Reserved.