public class ExceptionUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
rethrowIfFatal(Throwable throwable)
It is important never to catch all
Throwable s. |
static <T> T |
throwSneaky(IOException e) |
public static void rethrowIfFatal(Throwable throwable) throws Error, RuntimeException
Throwable
s. Some like
InterruptedException
should be rethrown. Based on
scala.util.control.NonFatal.
This method should be used with care.
If the Throwable
is fatal, it is rethrown, otherwise, this method just returns.
The input throwable is thrown if it is an Error
or a RuntimeException
.
Otherwise, the method wraps the throwable in a RuntimeException and throws that.
throwable
- to checkError
- the input throwable if it is fatalRuntimeException
- the input throwable if it is fatal - throws the original throwable
if is a RuntimeException
. Otherwise, wraps the throwable in a RuntimeException.public static <T> T throwSneaky(IOException e)
Copyright © 2008–2024 FasterXML. All rights reserved.