01: package com.xoetrope.task;
02:
03: /**
04: * StaticUtilities
05: *
06: * @author Brian Goetz and Tim Peierls
07: */
08: public class LaunderThrowable {
09: /**
10: * Coerce an unchecked Throwable to a RuntimeException
11: * <p/>
12: * If the Throwable is an Error, throw it; if it is a
13: * RuntimeException return it, otherwise throw IllegalStateException
14: */
15: public static RuntimeException launderThrowable(Throwable t) {
16: if (t instanceof RuntimeException)
17: return (RuntimeException) t;
18: else if (t instanceof Error)
19: throw (Error) t;
20: else
21: throw new IllegalStateException("Not unchecked", t);
22: }
23: }
|