Java examples for java.lang:Throwable
is Exception Caused By
import java.io.PrintWriter; import java.io.StringWriter; import javax.servlet.http.HttpServletRequest; public class Main{ //from w ww . j av a 2s .c om @SafeVarargs public static boolean isCausedBy(Exception ex, Class<? extends Exception>... causeExceptionClasses) { Throwable cause = ex.getCause(); while (cause != null) { for (Class<? extends Exception> causeClass : causeExceptionClasses) { if (causeClass.isInstance(cause)) { return true; } } cause = cause.getCause(); } return false; } }