org.norther.tammi.core.base
Class LogException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by org.norther.tammi.core.base.LogException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DefaultExceptionFilter

public class LogException
extends IOException

A generic exception supporting consistent run-time error management and configurable logging of run-time exceptions. Every exception to be logged by the server should be thrown as a LogException. An exception to be reported to the user should be thrown as a UserException.

Dynamic data can be added to messages as arguments. The first argument is always the date and time of the exception, and the last one the class name and message of an optional cause throwable. Other arguments can be given as parameters to the constructors of the exception. The following parameters are supported:

The exception maintains a log of thrown exceptions. The properties of the log can be configured separately (not available yet). The static log method can be used to log messages without throwing exceptions.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static int DEFAULT
          The default logging level of the exception.
static int ERROR
          The recoverable error level.
static int FATAL
          The fatal error level.
static int INFO
          The info level.
static int NONE
          The none level.
static int WARN
          The warn level.
static int WARNING
          The warning level.
 
Constructor Summary
LogException(int level, String message)
          Constructs an exception at the specified severity level with a message.
LogException(int level, String message, Object argument)
          Constructs an exception at the specified severity level with a message and argument.
LogException(int level, String message, Object argument, Throwable cause)
          Constructs an exception at the specified severity level with a message, argument and cause.
LogException(int level, String message, Throwable cause)
          Constructs an exception at the specified severity level with a message and cause.
LogException(int level, Throwable cause)
          Constructs an exception at the specified severity level with a cause.
LogException(String message)
          Constructs an exception with a message.
LogException(String message, Object argument)
          Constructs an exception with a message and argument.
LogException(String message, Object argument, Throwable cause)
          Constructs an exception with a message, argument and cause.
LogException(String message, Throwable cause)
          Constructs an exception with a message and cause.
LogException(Throwable cause)
          Constructs an exception with a cause.
 
Method Summary
 Object getArgument()
          Gets the argument in the exception.
 int getLevel()
          Gets the level of the exception.
 String getLocalizedMessage()
           
 String getLocalizedMessage(Locale locale)
          Gets a localized message for the specified locale.
 String getLocalizedMessage(Localizer localizer, Locale locale)
          Gets a localized message for the specified locale applying the given localizer.
protected  Log getMessageLog()
          Gets the message log.
 long getTime()
          Gets the time of the exception.
protected  void setLevel(int level)
          Sets the level of the exception.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
The none level.

See Also:
Constant Field Values

INFO

public static final int INFO
The info level.

See Also:
Constant Field Values

WARN

public static final int WARN
The warn level.

See Also:
Constant Field Values

WARNING

public static final int WARNING
The warning level.

See Also:
Constant Field Values

ERROR

public static final int ERROR
The recoverable error level.

See Also:
Constant Field Values

FATAL

public static final int FATAL
The fatal error level.

See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
The default logging level of the exception.

See Also:
Constant Field Values
Constructor Detail

LogException

public LogException(String message)
Constructs an exception with a message.

Parameters:
message - a message.

LogException

public LogException(Throwable cause)
Constructs an exception with a cause.

Parameters:
cause - a cause throwable.

LogException

public LogException(String message,
                    Throwable cause)
Constructs an exception with a message and cause.

Parameters:
message - a message.
cause - a cause throwable.

LogException

public LogException(String message,
                    Object argument)
Constructs an exception with a message and argument.

Parameters:
message - a message.
argument - an argument.

LogException

public LogException(String message,
                    Object argument,
                    Throwable cause)
Constructs an exception with a message, argument and cause.

Parameters:
message - a message.
argument - an argument.
cause - a cause throwable.

LogException

public LogException(int level,
                    String message)
Constructs an exception at the specified severity level with a message.

Parameters:
level - the level.
message - a message.

LogException

public LogException(int level,
                    Throwable cause)
Constructs an exception at the specified severity level with a cause.

Parameters:
level - the level.
cause - a cause throwable.

LogException

public LogException(int level,
                    String message,
                    Throwable cause)
Constructs an exception at the specified severity level with a message and cause.

Parameters:
level - the level.
message - a message.
cause - a cause throwable.

LogException

public LogException(int level,
                    String message,
                    Object argument)
Constructs an exception at the specified severity level with a message and argument.

Parameters:
level - the level.
message - a message.
argument - an argument.

LogException

public LogException(int level,
                    String message,
                    Object argument,
                    Throwable cause)
Constructs an exception at the specified severity level with a message, argument and cause.

Parameters:
level - the level.
message - a message.
argument - an argument.
cause - a cause throwable.
Method Detail

getLocalizedMessage

public String getLocalizedMessage()
Overrides:
getLocalizedMessage in class Throwable

getLocalizedMessage

public String getLocalizedMessage(Locale locale)
Gets a localized message for the specified locale.

Parameters:
locale - the locale of the message.
Returns:
the localized message or null.

getLocalizedMessage

public String getLocalizedMessage(Localizer localizer,
                                  Locale locale)
Gets a localized message for the specified locale applying the given localizer.

Parameters:
localizer - the localizer to apply.
locale - the locale of the message.
Returns:
the localized message or null.

getTime

public long getTime()
Gets the time of the exception.

Returns:
the time of the exception.

getLevel

public int getLevel()
Gets the level of the exception.

Returns:
the level of the exception.

getArgument

public Object getArgument()
Gets the argument in the exception.

Returns:
the argument in the exception.

setLevel

protected void setLevel(int level)
Sets the level of the exception.

Parameters:
level - the level.

getMessageLog

protected Log getMessageLog()
Gets the message log.

Returns:
the log.


Copyright © 2004 The Norther Organization. All rights reserved.