unchecked
public static RuntimeException unchecked(Throwable e)
Rethrows a checked exception as unchecked exception. This method tricks the compiler into
thinking the exception is unchecked, rather than wrapping the given exception in a new
RuntimeException
.
This method never returns. Nevertheless, it specifies a return type so it can be invoked as
throw unchecked(e)
in contexts where an exception type is syntactically required
(e.g. when the enclosing method is non-void).
- Parameters:
e
- Throwable to be made unchecked.
- Returns:
- This will never return anything. It's here to trick the compiler.