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
FieldsModifier and TypeFieldDescriptionprotected List<CmsException> The list of internal exceptions.protected booleanIndicates if the message has been set as individual message.Fields inherited from class org.opencms.main.CmsException
m_message -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new multi exception, a container for several exception messages.CmsMultiException(List<CmsException> exceptions) Creates a new multi exception for the given list ofinstances.CmsExceptionCmsMultiException(CmsMessageContainer message) Creates a new multi exception using the given base message. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddException(CmsException exception) Adds an Exception to the list of Exceptions kept in this multi Exception.voidaddExceptions(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.booleanReturnstrueif this multi exceptions contains at last one individual Exception.booleanReturnstrueif this multi message has an individual base message set.protected voidsetExceptions(List<CmsException> exceptions) Updates the internal list of stored exceptions.voidsetMessage(CmsMessageContainer message) Sets an individual message for the multi exception base message.protected voidUpdates the intenal message for the Exception.Methods inherited from class org.opencms.main.CmsException
getFormattedErrorstack, getMessage, getMessageContainer, getStackTraceAsStringMethods 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 ofinstances.CmsException- Parameters:
exceptions- a list ofinstancesCmsException
-
-
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:CmsExceptionCreates a copied instance of this localized exception.- Overrides:
createExceptionin 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:
getLocalizedMessagein interfaceI_CmsThrowable- Overrides:
getLocalizedMessagein 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:
getLocalizedMessagein interfaceI_CmsThrowable- Overrides:
getLocalizedMessagein 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
Returnstrueif this multi exceptions contains at last one individual Exception.- Returns:
trueif this multi exceptions contains at last one individual Exception
-
hasIndividualMessage
Returnstrueif this multi message has an individual base message set.- Returns:
trueif 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_1If
nullis 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.
-