org.osconsulting.jerr
Class JErr

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.osconsulting.jerr.JErr
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
JErrConfigError

public class JErr
extends java.lang.Exception

The JError class is the base class for all JError subclasses classes. The main purpose of this class is to provide a error code and localized message, based on the user's locale (not just the server's locale). Note that the JError class depends heavily on the JErrorCode being set. The ErrorCodes are defined in the implementing JErrorCategory classes. For the JErr there is one category org.osconsulting.jerr.handler.JErrErrorCategory containing all ErrorCodes.

Author:
Kurt T Stam Copyright 2006 osConsulting.org Kurt Stam and Shahar Bar
See Also:
Serialized Form

Constructor Summary
JErr(JErrCode jErrorCode)
          Constructor, taking an error code.
JErr(JErrCode jErrorCode, java.lang.String localizedMessage)
          Constructor.
JErr(JErrCode jErrorCode, java.lang.String[] args)
          Constructor, taking an error code.
JErr(JErrCode jErrorCode, java.lang.String[] args, java.lang.String localizedMessage)
          Constructor.
JErr(JErrCode jErrorCode, java.lang.String[] args, java.lang.String localizedMessage, java.lang.Throwable cause)
          Constructor.
JErr(JErrCode errorCode, java.lang.String[] args, java.lang.Throwable cause)
          Constructor.
JErr(JErrCode jErrorCode, java.lang.String localizedMessage, java.lang.Throwable cause)
          Constructor.
JErr(JErrCode errorCode, java.lang.Throwable cause)
          Constructor.
 
Method Summary
 JErrCode getJErrorCode()
          Gets the error code attached to this error.
 java.lang.String getLocalizedMessage()
          Overriding the base class, since the localizedMessage is stored in the message field of this class.
 java.lang.String getLocalizedMessage(java.util.Locale locale)
          Gets the localized error message, based on the locale value passed in.
 void setJErrorCode(JErrCode jErrorCode)
          Sets the error code.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, 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

JErr

public JErr(JErrCode jErrorCode)
Constructor, taking an error code. The error code is a required argument.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).

JErr

public JErr(JErrCode jErrorCode,
            java.lang.String[] args)
Constructor, taking an error code. The error code is a required argument. In addition an array of strings can be passed in for string replacement in message. For example "{0}" will be replaced by the first argument in the array, "{1}" with the second argument. The arguments may be filenames etc. Make sure to pass in locale insensive strings.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).
args - argument array which will be used to replace variables.

JErr

public JErr(JErrCode jErrorCode,
            java.lang.String[] args,
            java.lang.String localizedMessage,
            java.lang.Throwable cause)
Constructor. Note that the error code is a required argument.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).
localizedMessage - error message localized to the locale of the server.
cause - the exception that caused this error

JErr

public JErr(JErrCode jErrorCode,
            java.lang.String localizedMessage,
            java.lang.Throwable cause)
Constructor. Note that the error code is a required argument.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).
localizedMessage - error message localized to the locale of the server.
cause - the exception that caused this error

JErr

public JErr(JErrCode jErrorCode,
            java.lang.String[] args,
            java.lang.String localizedMessage)
Constructor.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).
localizedMessage - the error message in the server's locale.

JErr

public JErr(JErrCode jErrorCode,
            java.lang.String localizedMessage)
Constructor.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).
localizedMessage - the error message in the server's locale.

JErr

public JErr(JErrCode errorCode,
            java.lang.String[] args,
            java.lang.Throwable cause)
Constructor.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).
cause - the exception that caused this exception.

JErr

public JErr(JErrCode errorCode,
            java.lang.Throwable cause)
Constructor.

Parameters:
errorCode - the errorCode as defined in the implementing JErrorCategory class to which this errorCode belongs (required argument).
cause - the exception that caused this exception.
Method Detail

getJErrorCode

public JErrCode getJErrorCode()
Gets the error code attached to this error.

Returns:
the error code.

setJErrorCode

public void setJErrorCode(JErrCode jErrorCode)
Sets the error code.

Parameters:
errorCode - - the error code attached to this error.

getLocalizedMessage

public java.lang.String getLocalizedMessage()
Overriding the base class, since the localizedMessage is stored in the message field of this class. There is no API to set the value of localizedMessage of Exception.

Overrides:
getLocalizedMessage in class java.lang.Throwable

getLocalizedMessage

public java.lang.String getLocalizedMessage(java.util.Locale locale)
                                     throws JErrConfigError
Gets the localized error message, based on the locale value passed in. For the search strategy of the localized message see MessageStore.getLocalizedMessage(). Note that a Locale is made up of Language, Country and Variant.

Parameters:
locale - the locale used to find the localized message.
Returns:
the localized error message
Throws:
JErrConfigError

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Throwable
See Also:
String.toString()


Copyright © 2006-2007. All Rights Reserved.