com.thebuzzmedia.exiftool.commons.exceptions.Exceptions Maven / Gradle / Ivy
package com.thebuzzmedia.exiftool.commons.exceptions;
/**
* Static Exceptions Utilities.
*/
public final class Exceptions {
private Exceptions() {
}
/**
* Coerce an unchecked Throwable to a RuntimeException:
*
*
* - If the Throwable is an Error, throw it.
* - If it is a {@link RuntimeException} return it.
* - Otherwise, throw {@link IllegalStateException}.
*
*
* @param t Original throwable.
* @return Wrapped exception.
*/
public static RuntimeException launderThrowable(Throwable t) {
if (t instanceof RuntimeException) {
return (RuntimeException) t;
}
else if (t instanceof Error) {
throw (Error) t;
}
else {
throw new IllegalStateException("Not unchecked", t);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy