00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package com.sleepycat.util;
00011
00020 public class ExceptionUnwrapper {
00021
00035 public static Exception unwrap(Exception e) {
00036
00037 Throwable t = unwrapAny(e);
00038 if (t instanceof Exception) {
00039 return (Exception) t;
00040 } else if (t instanceof Error) {
00041 throw (Error) t;
00042 } else {
00043 throw new IllegalArgumentException("Not Exception or Error: " + t);
00044 }
00045 }
00046
00054 public static Throwable unwrapAny(Throwable e) {
00055
00056 while (true) {
00057 if (e instanceof ExceptionWrapper) {
00058 Throwable e2 = ((ExceptionWrapper) e).getCause();
00059 if (e2 == null) {
00060 return e;
00061 } else {
00062 e = e2;
00063 }
00064 } else {
00065 return e;
00066 }
00067 }
00068 }
00069 }