Package org.opencms.main
Class CmsMultiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.opencms.main.CmsException
org.opencms.main.CmsMultiException
- All Implemented Interfaces:
Serializable
,I_CmsThrowable
A multi exception is a container for several exception messages that may be caused by an internal operation.
This is provided so that the user can see a full picture of all the issues that have been caused in an operation, rather then only one (usually the first) issue.
- Since:
- 2.0.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected List<CmsException>
The list of internal exceptions.protected boolean
Indicates if the message has been set as individual message.Fields inherited from class org.opencms.main.CmsException
m_message
-
Constructor Summary
ConstructorDescriptionCreates a new multi exception, a container for several exception messages.CmsMultiException
(List<CmsException> exceptions) Creates a new multi exception for the given list of
instances.CmsException
CmsMultiException
(CmsMessageContainer message) Creates a new multi exception using the given base message. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addException
(CmsException exception) Adds an Exception to the list of Exceptions kept in this multi Exception.void
addExceptions
(List<CmsException> exceptions) Adds all Exceptions in the given List to the list of Exceptions kept in this multi Exception.createException
(CmsMessageContainer container, Throwable cause) Creates a copied instance of this localized exception.Returns the (unmodifiable) List of exceptions that are stored in this multi exception.Returns a localized message composed of all contained exceptions.getLocalizedMessage
(Locale locale) Returns a localized message for the given locale composed of all contained exceptions.getMessage
(Locale locale) Returns the individual message (if set) or an empty String.boolean
Returnstrue
if this multi exceptions contains at last one individual Exception.boolean
Returnstrue
if this multi message has an individual base message set.protected void
setExceptions
(List<CmsException> exceptions) Updates the internal list of stored exceptions.void
setMessage
(CmsMessageContainer message) Sets an individual message for the multi exception base message.protected void
Updates the intenal message for the Exception.Methods inherited from class org.opencms.main.CmsException
getFormattedErrorstack, getMessage, getMessageContainer, getStackTraceAsString
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
m_exceptions
The list of internal exceptions. -
m_individualMessage
Indicates if the message has been set as individual message.
-
-
Constructor Details
-
CmsMultiException
public CmsMultiException()Creates a new multi exception, a container for several exception messages. -
CmsMultiException
Creates a new multi exception using the given base message.- Parameters:
message
- the basic message to use
-
CmsMultiException
Creates a new multi exception for the given list of
instances.CmsException
- Parameters:
exceptions
- a list of
instancesCmsException
-
-
Method Details
-
addException
Adds an Exception to the list of Exceptions kept in this multi Exception.- Parameters:
exception
- the Exception to add
-
addExceptions
Adds all Exceptions in the given List to the list of Exceptions kept in this multi Exception.- Parameters:
exceptions
- the Exceptions to add
-
createException
Description copied from class:CmsException
Creates a copied instance of this localized exception.- Overrides:
createException
in classCmsException
- Parameters:
container
- the message containercause
- the root cause- Returns:
- a copied instance of this localized exception
- See Also:
-
getExceptions
Returns the (unmodifiable) List of exceptions that are stored in this multi exception.- Returns:
- the (unmodifiable) List of exceptions that are stored in this multi exception
-
getLocalizedMessage
Returns a localized message composed of all contained exceptions.- Specified by:
getLocalizedMessage
in interfaceI_CmsThrowable
- Overrides:
getLocalizedMessage
in classCmsException
- Returns:
- a localized exception message based on the OpenCms default locale
- See Also:
-
getLocalizedMessage
Returns a localized message for the given locale composed of all contained exceptions.- Specified by:
getLocalizedMessage
in interfaceI_CmsThrowable
- Overrides:
getLocalizedMessage
in classCmsException
- Parameters:
locale
- the Locale to get the message for- Returns:
- a localized exception message based on the given Locale
- See Also:
-
getMessage
Returns the individual message (if set) or an empty String.- Parameters:
locale
- the locale for the message to generate- Returns:
- the individual message (if set) or an empty String
-
hasExceptions
Returnstrue
if this multi exceptions contains at last one individual Exception.- Returns:
true
if this multi exceptions contains at last one individual Exception
-
hasIndividualMessage
Returnstrue
if this multi message has an individual base message set.- Returns:
true
if this multi message has an individual base message set- See Also:
-
setMessage
Sets an individual message for the multi exception base message.If no individual message has been set, a default message using the key
will be used.Messages.ERR_MULTI_EXCEPTION_1
If
null
is given as parameter, any individual message that has been set is reset to the default message.- Parameters:
message
- the message to set
-
setExceptions
Updates the internal list of stored exceptions.- Parameters:
exceptions
- the exceptions to use (will replace the current exception list)
-
updateMessage
Updates the intenal message for the Exception.
-