Java examples for java.lang:Throwable
unwrap Throwable
//package com.java2s; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.UndeclaredThrowableException; public class Main { public static Throwable unwrapThrowable(Throwable wrapped) { Throwable unwrapped = wrapped; while (true) { if (unwrapped instanceof InvocationTargetException) { unwrapped = ((InvocationTargetException) wrapped) .getTargetException(); } else if (unwrapped instanceof UndeclaredThrowableException) { unwrapped = ((UndeclaredThrowableException) wrapped) .getUndeclaredThrowable(); } else { return unwrapped; }//from ww w .j a v a2 s .c om } } }