Package church.i18n.processing.exception
Class ExceptionUtils
java.lang.Object
church.i18n.processing.exception.ExceptionUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Optional<ProcessingException> getWrappedException(@Nullable Throwable original) It may happen that external libraries wrap our exception into different exception.static @NotNull ProcessingExceptionrewrapWrapped(@NotNull Throwable original, @NotNull String newCode, @Nullable Object... newParams) Finds innerProcessingExceptionand remaps it into a newProcessingExceptionwith a new code.static Optional<ProcessingException> tryTranslate(@NotNull Exception e, @NotNull ExceptionTranslator<Exception>... translators) static @NotNull ProcessingExceptionwrap(@NotNull ProcessingException original, @NotNull String newCode, @Nullable Object... newParams) Create a new instance ofProcessingExceptionwith different code and places the original exception as the cause of newly created exception.
-
Method Details
-
getWrappedException
@NotNull public static @NotNull Optional<ProcessingException> getWrappedException(@Nullable @Nullable Throwable original) It may happen that external libraries wrap our exception into different exception. Method finds the firstProcessingExceptionthat is wrapped in the original exception cause.- Parameters:
original- Original exception to check.- Returns:
- Original wrapped
ProcessingExceptionthat was originally thrown. When there is no such exception it returnsOptional.empty().
-
wrap
@NotNull public static @NotNull ProcessingException wrap(@NotNull @NotNull ProcessingException original, @NotNull @NotNull String newCode, @Nullable @Nullable Object... newParams) Create a new instance ofProcessingExceptionwith different code and places the original exception as the cause of newly created exception.- Parameters:
original- Original exception.newCode- New mapping code for new exception.newParams- Params of the new exception message.- Returns:
- New instance of mapped exception.
-
rewrapWrapped
@NotNull public static @NotNull ProcessingException rewrapWrapped(@NotNull @NotNull Throwable original, @NotNull @NotNull String newCode, @Nullable @Nullable Object... newParams) Finds innerProcessingExceptionand remaps it into a newProcessingExceptionwith a new code.- Parameters:
original- Original thrown exception.newCode- New mapping code.newParams- Parameters for the original mapping.- Returns:
- Newly mapped exception in the case there was inner
ProcessingExceptioncause, otherwise it creates a new instance ofProcessingExceptionwith the cause oforiginalexception.
-
tryTranslate
@SafeVarargs public static Optional<ProcessingException> tryTranslate(@NotNull @NotNull Exception e, @NotNull @NotNull ExceptionTranslator<Exception>... translators)
-