All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.yawp.commons.utils.ThrownExceptionsUtils Maven / Gradle / Ivy

There is a newer version: 2.08alpha
Show newest version
package io.yawp.commons.utils;

import java.lang.reflect.InvocationTargetException;

public final class ThrownExceptionsUtils {

	private ThrownExceptionsUtils() {
		throw new RuntimeException("Should never be instanciated.");
	}

	public static RuntimeException handle(Throwable ex) {
		Throwable cause = ex;
		while (cause instanceof InvocationTargetException) {
			cause = cause.getCause();
		}

		if (cause instanceof RuntimeException) {
			return (RuntimeException) cause;
		}

		return new RuntimeException(cause);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy