Class WrappedException

All Implemented Interfaces:
Serializable

public final class WrappedException extends RuntimeException
Exception wrapper for converting checked exceptions to unchecked. Features: - Preserves original stack trace - Handles InvocationTargetException unwrapping - Supports custom error messages - Maintains existing RuntimeExceptions Used to simplify exception handling while preserving error context.
Author:
npiedeloup
See Also:
  • Method Details

    • wrap

      public static RuntimeException wrap(Throwable th)
      Wraps any exception into a RuntimeException. Preserves original exception if already unchecked.
      Parameters:
      th - Original exception
      Returns:
      RuntimeException wrapper
    • wrap

      public static RuntimeException wrap(Throwable th, String msg, Object... params)
      Wraps any exception into a RuntimeException with custom message. Preserves original exception if already unchecked.
      Parameters:
      th - Original exception
      msg - Custom message
      params - Message parameters
      Returns:
      RuntimeException wrapper
    • unwrap

      public Throwable unwrap()
      Retrieves the original wrapped exception.
      Returns:
      Original exception