org.opencms.main
Class CmsException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.opencms.main.CmsException
All Implemented Interfaces:
java.io.Serializable, I_CmsThrowable
Direct Known Subclasses:
CmsConfigurationException, CmsDataAccessException, CmsFlexCacheException, CmsImportExportException, CmsIndexException, CmsLoaderException, CmsLockException, CmsMessageException, CmsMultiException, CmsPasswordEncryptionException, CmsPublishException, CmsResourceInitException, CmsRfsException, CmsSchedulerException, CmsSearchException, CmsSecurityException, CmsStaticExportException, CmsSynchronizeException, CmsWidgetException, CmsWorkplaceException, CmsXmlException

public class CmsException
extends java.lang.Exception
implements I_CmsThrowable

Master exception type for all exceptions caused in OpenCms.

Since:
6.0.0
Version:
$Revision: 1.42 $
Author:
Alexander Kandzior, Michael Emmerich, Michael Moossen, Jan Baudisch
See Also:
Serialized Form

Field Summary
protected  CmsMessageContainer m_message
          The container for the localized message.
 
Constructor Summary
CmsException(CmsMessageContainer message)
          Creates a new localized Exception.
CmsException(CmsMessageContainer message, java.lang.Throwable cause)
          Creates a new localized Exception that also containes a root cause.
 
Method Summary
 CmsException createException(CmsMessageContainer container, java.lang.Throwable cause)
          Creates a copied instance of this localized exception.
static java.lang.String getFormattedErrorstack(java.lang.Throwable t)
          Returns the HTML formatted error stack of a Throwable.
 java.lang.String getLocalizedMessage()
          Returns a localized exception message based on the OpenCms default locale.
 java.lang.String getLocalizedMessage(java.util.Locale locale)
          Returns a localized exception message based on the given Locale.
 java.lang.String getMessage()
          Returns a localized exception message based on the OpenCms default locale.
 CmsMessageContainer getMessageContainer()
          Returns the localized message container used to build this localized exception.
static java.lang.String getStackTraceAsString(java.lang.Throwable e)
          Returns the stack trace (including the message) of an exception as a String.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, 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

m_message

protected CmsMessageContainer m_message
The container for the localized message.

Constructor Detail

CmsException

public CmsException(CmsMessageContainer message)
Creates a new localized Exception.

Parameters:
message - the localized message container to use

CmsException

public CmsException(CmsMessageContainer message,
                    java.lang.Throwable cause)
Creates a new localized Exception that also containes a root cause.

Parameters:
message - the localized message container to use
cause - the Exception root cause
Method Detail

getFormattedErrorstack

public static java.lang.String getFormattedErrorstack(java.lang.Throwable t)
Returns the HTML formatted error stack of a Throwable.

The error stack is used by the common error screen that is displayed if an error occurs.

Parameters:
t - the throwable to get the errorstack from
Returns:
the formatted value of the errorstack parameter

getStackTraceAsString

public static java.lang.String getStackTraceAsString(java.lang.Throwable e)
Returns the stack trace (including the message) of an exception as a String.

If the exception is a CmsException, also writes the root cause to the String.

Parameters:
e - the exception to get the stack trace from
Returns:
the stack trace of an exception as a String

createException

public CmsException createException(CmsMessageContainer container,
                                    java.lang.Throwable cause)
Creates a copied instance of this localized exception.

Parameters:
container - the message container
cause - the root cause
Returns:
a copied instance of this localized exception

getLocalizedMessage

public java.lang.String getLocalizedMessage()
Description copied from interface: I_CmsThrowable
Returns a localized exception message based on the OpenCms default locale.

Specified by:
getLocalizedMessage in interface I_CmsThrowable
Overrides:
getLocalizedMessage in class java.lang.Throwable
Returns:
a localized exception message based on the OpenCms default locale
See Also:
I_CmsThrowable.getLocalizedMessage()

getLocalizedMessage

public java.lang.String getLocalizedMessage(java.util.Locale locale)
Description copied from interface: I_CmsThrowable
Returns a localized exception message based on the given Locale.

Specified by:
getLocalizedMessage in interface I_CmsThrowable
Parameters:
locale - the Locale to get the message for
Returns:
a localized exception message based on the given Locale
See Also:
I_CmsThrowable.getLocalizedMessage(Locale)

getMessage

public java.lang.String getMessage()
Description copied from interface: I_CmsThrowable
Returns a localized exception message based on the OpenCms default locale.

Specified by:
getMessage in interface I_CmsThrowable
Overrides:
getMessage in class java.lang.Throwable
Returns:
a localized exception message based on the OpenCms default locale
See Also:
Throwable.getMessage()

getMessageContainer

public CmsMessageContainer getMessageContainer()
Description copied from interface: I_CmsThrowable
Returns the localized message container used to build this localized exception.

Specified by:
getMessageContainer in interface I_CmsThrowable
Returns:
the localized message container used to build this localized exception
See Also:
I_CmsThrowable.getMessageContainer()