Java examples for java.lang:Throwable
get Most Specific Cause Throwable
//package com.java2s; public class Main { public static Throwable getMostSpecificCause(Throwable ex) { Throwable rootCause = getRootCause(ex); return (rootCause != null ? rootCause : ex); }/*from w ww .j a va 2s. c o m*/ public static Throwable getRootCause(Throwable ex) { Throwable rootCause = null; Throwable cause = ex.getCause(); while (cause != null && cause != rootCause) { rootCause = cause; cause = cause.getCause(); } return rootCause; } }