com.buildforge.services.common
Class ServiceException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.buildforge.services.common.ServiceException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
APIException, ProtocolException

public class ServiceException
extends java.lang.Exception

Generic, internationalized exception class for the services layer.

See Also:
Serialized Form

Nested Class Summary
 class ServiceException.WrappedServiceException
          This is a simple wrapping class that allows a ServiceException to be thrown as an unchecked exception.
 
Field Summary
static java.lang.Class<ServiceException> CLASS
          Resolve the class
 
Constructor Summary
ServiceException(MessageDBO msg)
          Construct a new ServiceException from a pre-built message.
ServiceException(MessageDBO msg, java.lang.Throwable cause)
          Construct a new ServiceException from a pre-built message.
ServiceException(java.lang.String id)
          Construct a new ServiceException.
ServiceException(java.lang.String id, int arg)
          Construct a new ServiceException.
ServiceException(java.lang.String id, int arg, java.lang.Throwable cause)
          Construct a new ServiceException.
ServiceException(java.lang.String id, java.lang.String arg)
          Construct a new ServiceException.
ServiceException(java.lang.String id, java.lang.String[] args)
          Construct a new ServiceException.
ServiceException(java.lang.String id, java.lang.String[] args, java.lang.Throwable cause)
          Construct a new ServiceException
ServiceException(java.lang.String id, java.lang.String arg, java.lang.Throwable cause)
          Construct a new ServiceException.
ServiceException(java.lang.String id, java.lang.Throwable cause)
          Construct a new ServiceException.
 
Method Summary
 java.lang.String getMessage()
           
 java.lang.String getMessageKey()
          Gets the error id used when constructing this exception.
 MessageDBO getMessageObject()
          Returns the message object that was created to represent this exception's message text.
 ServiceException.WrappedServiceException wrap()
          Wraps this exception so that it can be propogated as an unchecked exception.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS

public static final java.lang.Class<ServiceException> CLASS
Resolve the class

Constructor Detail

ServiceException

public ServiceException(MessageDBO msg)
Construct a new ServiceException from a pre-built message. The cause will not be initialized.

Parameters:
msg - the internationalized error message
Throws:
java.lang.NullPointerException - if msg is null

ServiceException

public ServiceException(MessageDBO msg,
                        java.lang.Throwable cause)
Construct a new ServiceException from a pre-built message.

Parameters:
msg - the internationalized error message
cause - an exception that caused this exception to occur
Throws:
java.lang.NullPointerException - if msg is null

ServiceException

public ServiceException(java.lang.String id)
Construct a new ServiceException. The cause will not be initialized, and the message must not require any arguments.

Parameters:
id - a unique error id for a translatable message

ServiceException

public ServiceException(java.lang.String id,
                        java.lang.String[] args)
Construct a new ServiceException. The cause will not be initialized.

Parameters:
id - a unique error id for a translatable message
args - arguments for the translation

ServiceException

public ServiceException(java.lang.String id,
                        int arg)
Construct a new ServiceException. The cause will not be initialized. This is a convenience method for the fairly common case where the exception message takes a single integer as its argument.

Parameters:
id - a unique error id for a translatable message
arg - a single argument for the translation

ServiceException

public ServiceException(java.lang.String id,
                        java.lang.String arg)
Construct a new ServiceException. The cause will not be initialized. This is a convenience method for the fairly common case where the exception message takes a single String as its argument.

Parameters:
id - a unique error id for a translatable message
arg - a single argument for the translation

ServiceException

public ServiceException(java.lang.String id,
                        java.lang.Throwable cause)
Construct a new ServiceException. The message must not require any arguments.

Parameters:
id - a unique error id for a translatable message
cause - the exception to use when initializing the cause

ServiceException

public ServiceException(java.lang.String id,
                        java.lang.String[] args,
                        java.lang.Throwable cause)
Construct a new ServiceException

Parameters:
id - the unique id of the internationalized message to use
args - arguments for the translation
cause - the exception to use when initializing the cause

ServiceException

public ServiceException(java.lang.String id,
                        int arg,
                        java.lang.Throwable cause)
Construct a new ServiceException. This is a convenience method for the fairly common case where the exception message takes a single integer as its argument.

Parameters:
id - a unique error id for a translatable message
arg - a single argument for the translation
cause - the exception to use when initializing the cause

ServiceException

public ServiceException(java.lang.String id,
                        java.lang.String arg,
                        java.lang.Throwable cause)
Construct a new ServiceException. This is a convenience method for the fairly common case where the exception message takes a single String as its argument.

Parameters:
id - a unique error id for a translatable message
arg - a single argument for the translation
cause - the exception to use when initializing the cause
Method Detail

getMessageKey

public java.lang.String getMessageKey()
Gets the error id used when constructing this exception.

Returns:
the error id

getMessage

public java.lang.String getMessage()
Overrides:
getMessage in class java.lang.Throwable

getMessageObject

public MessageDBO getMessageObject()
Returns the message object that was created to represent this exception's message text.

Returns:
the message object

wrap

public ServiceException.WrappedServiceException wrap()
Wraps this exception so that it can be propogated as an unchecked exception.

Returns:
the wrapped exception