-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAppExceptionMessageList(AppException appException, Locale locale) Returns listed SingleAppExceptions (= AppExceptions with messages).getErrLogString(Throwable throwable, String additionalMessage, Locale locale) Returns strings or error log.getExceptionListWithMessages(Throwable throwable) Returns listed exceptions with messages.getExceptionMessage(Throwable throwable, boolean needsDetails) Returns exception message for 1 exception.getExceptionMessage(Throwable throwable, Locale locale, boolean needsDetails) Returns exception message for 1 exception.getSingleAppExceptionList(AppException appException) Returns listed SingleAppExceptions (= AppExceptions with messages).
-
Constructor Details
-
ExceptionUtil
public ExceptionUtil()
-
-
Method Details
-
getExceptionMessage
@Nonnull public List<String> getExceptionMessage(@Nonnull Throwable throwable, boolean needsDetails) Returns exception message for 1 exception.This method covers all the exceptions including Java standard exceptions, ConstraintViolationException used in Bean Validation and AppExceptions defined in this library.
One exception normally has one message, but one ConstraintViolationException can have multiple messages so the return type is not a
String, but aList<String>.- Parameters:
throwable- throwableneedsDetails- Sets if detail message is needed. This is true with log output or batch processing. False when you show the message on screen.- Returns:
- a list of messages
-
getExceptionMessage
@Nonnull public List<String> getExceptionMessage(@Nonnull Throwable throwable, @Nullable Locale locale, boolean needsDetails) Returns exception message for 1 exception.This method covers all the exceptions including Java standard exceptions, ConstraintViolationException used in Bean Validation and AppExceptions defined in this library.
One exception normally has one message, but one ConstraintViolationException can have multiple messages so the return type is not a
String, but aList<String>.- Parameters:
throwable- throwablelocale- locale, may benullwhich is treated asLocale.getDefault().needsDetails- Sets if detail message is needed. This is true with log output or batch processing. False when you show the message on screen.- Returns:
- a list of messages
-
getExceptionListWithMessages
Returns listed exceptions with messages.This is used for log output to see error messages easily.
This is not used for online because in online apps messages shown to users is only SingleAppExceptions.
- Parameters:
throwable- throwable- Returns:
- a list of Throwables
-
getSingleAppExceptionList
@Nonnull public List<SingleAppException> getSingleAppExceptionList(@Nonnull AppException appException) Returns listed SingleAppExceptions (= AppExceptions with messages).This is not used for online
- Parameters:
appException- AppException- Returns:
- list of SingleAppException
-
getAppExceptionMessageList
@Nonnull public List<String> getAppExceptionMessageList(@Nonnull AppException appException, @Nullable Locale locale) Returns listed SingleAppExceptions (= AppExceptions with messages).This is used for online.
The overload method with RuntimeAppException won't be created because getCause() of RuntimeAppException is AppException and it is not needed by then.
- Parameters:
appException- AppExceptionlocale- locale, may benullwhich is treated asLocale.getDefault().- Returns:
- list of SingleAppException
-
getErrLogString
@Nonnull public String getErrLogString(@Nonnull Throwable throwable, @Nullable String additionalMessage, @Nullable Locale locale) Returns strings or error log.- Parameters:
throwable- throwableadditionalMessage- additional message, may benullif noadditionalMessageis needed. In the case ofnullno additional message is output.locale- locale, may benullwhich is treated asLocale.getDefault().- Returns:
- error log string
-