-
Method Summary
Modifier and TypeMethodDescriptiongetAppExceptionMessageList(AppException appException, Locale locale) Returns listed SingleAppExceptions (= AppExceptions with messages).static StringgetErrLogShortString(Throwable throwable, String additionalMessage, Locale locale, int packagesShown) Returns strings or error log.static StringgetErrLogString(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.static List<SingleAppException> getSingleAppExceptionList(AppException appException) Returns listed SingleAppExceptions (= AppExceptions with messages).
-
Method Details
-
getExceptionMessage
@Nonnull public static List<String> getExceptionMessage(@RequireNonnull Throwable throwable, boolean needsDetails) Returns exception message for 1 exception.This method covers all the exceptions including Java standard exceptions, ConstraintViolationException used in Jakarta 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 static List<String> getExceptionMessage(@RequireNonnull 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 Jakarta 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
@Nonnull public static List<Throwable> getExceptionListWithMessages(@RequireNonnull Throwable throwable) 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 static List<SingleAppException> getSingleAppExceptionList(@RequireNonnull AppException appException) Returns listed SingleAppExceptions (= AppExceptions with messages).This is not used for online
- Parameters:
appException- AppException- Returns:
- list of SingleAppException
-
getAppExceptionMessageList
@Nonnull public static List<String> getAppExceptionMessageList(@RequireNonnull 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
-
getErrLogShortString
@Nonnull public static String getErrLogShortString(@RequireNonnull Throwable throwable, @Nullable String additionalMessage, @Nullable Locale locale, int packagesShown) 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().packagesShown- packages shown in the stack traces. This is used when the log displaying area is small.- Returns:
- error log string
-
getErrLogString
@Nonnull public static String getErrLogString(@RequireNonnull 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
-