net.jqwik.engine.support.JqwikExceptionSupport Maven / Gradle / Ivy
package net.jqwik.engine.support;
public class JqwikExceptionSupport {
/**
* Throw the supplied {@link Throwable}, masked as an
* unchecked exception.
*
* @param t the Throwable to be wrapped
* @param type of the value to return
* @return Fake return to make using the method a bit simpler
*/
public static T throwAsUncheckedException(Throwable t) {
JqwikExceptionSupport.throwAs(t);
// Will never get here
return null;
}
@SuppressWarnings("unchecked")
private static void throwAs(Throwable t) throws T {
throw (T) t;
}
public static void rethrowIfBlacklisted(Throwable exception) {
if (exception instanceof OutOfMemoryError) {
throwAsUncheckedException(exception);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy