java.lang.Object
church.i18n.processing.exception.ExceptionUtils

public final class ExceptionUtils extends Object
  • 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 first ProcessingException that is wrapped in the original exception cause.
      Parameters:
      original - Original exception to check.
      Returns:
      Original wrapped ProcessingException that was originally thrown. When there is no such exception it returns Optional.empty().
    • wrap

      @NotNull public static @NotNull ProcessingException wrap(@NotNull @NotNull ProcessingException original, @NotNull @NotNull String newCode, @Nullable @Nullable Object... newParams)
      Create a new instance of ProcessingException with 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 inner ProcessingException and remaps it into a new ProcessingException with 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 ProcessingException cause, otherwise it creates a new instance of ProcessingException with the cause of original exception.
    • tryTranslate

      @SafeVarargs public static Optional<ProcessingException> tryTranslate(@NotNull @NotNull Exception e, @NotNull @NotNull ExceptionTranslator<Exception>... translators)