1 16 package scriptella.util; 17 18 import java.sql.SQLException ; 19 20 26 public final class ExceptionUtils { 27 private ExceptionUtils() { 28 } 29 30 38 public static Throwable getCause(Throwable throwable) { 39 if (throwable.getCause() != null) { 40 return throwable.getCause(); 41 } 42 if (throwable instanceof SQLException ) { 43 return ((SQLException ) throwable).getNextException(); 44 } 45 return null; 46 } 47 48 53 public static void throwUnchecked(Throwable unchecked) { 54 if (unchecked instanceof Error ) { 55 throw (Error ) unchecked; 56 } 57 if (unchecked instanceof RuntimeException ) { 58 throw (RuntimeException ) unchecked; 59 } 60 throw new IllegalStateException ("Unchecked throwable expected but was " + unchecked.getClass(), unchecked); 61 } 62 63 67 public static void ignoreThrowable(Throwable throwable) { 68 } 69 70 } 71 | Popular Tags |