Throwables
Static utility methods pertaining to instances of [[Throwable]]
.
- Since
3.0
Value members
Concrete methods
Propagates <code>throwable</code> as-is if it is an instance of [[RuntimeException]]
or
[[Error]]
, or else as a last resort, wraps
it in a <code>RuntimeException</code> then propagates.
Propagates <code>throwable</code> as-is if it is an instance of [[RuntimeException]]
or
[[Error]]
, or else as a last resort, wraps
it in a <code>RuntimeException</code> then propagates.
This method always throws an exception. The <code>RuntimeException</code> return type is only for client code to make Java type system happy in case a return value is required by the enclosing method. Example usage:
<pre> T doSomething() { try { return someMethodThatCouldThrowAnything(); } catch (IKnowWhatToDoWithThisException e) { return handle(e); } catch (Throwable t) { throw Throwables.propagate(t); } } </pre>
- Value Params
- throwable
the Throwable to propagate
- Returns
nothing will ever be returned; this return type is only for your convenience, as illustrated in the example above
Propagates <code>throwable</code> exactly as-is, if and only if it is an instance of <code>declaredType</code>. Example usage:
Propagates <code>throwable</code> exactly as-is, if and only if it is an instance of <code>declaredType</code>. Example usage:
<pre> try { someMethodThatCouldThrowAnything(); } catch (IKnowWhatToDoWithThisException e) { handle(e); } catch (Throwable t) { Throwables.propagateIfInstanceOf(t, IOException.class); Throwables.propagateIfInstanceOf(t, SQLException.class); throw Throwables.propagate(t); } </pre>
Returns a string containing the result of [[Throwable#toString() toString()]]
, followed by
the full, recursive
stack trace of <code>throwable</code>. Note that you probably should not be
parsing the resulting string; if you need programmatic access to the stack
frames, you can call [[Throwable#getStackTrace()]]
.
Returns a string containing the result of [[Throwable#toString() toString()]]
, followed by
the full, recursive
stack trace of <code>throwable</code>. Note that you probably should not be
parsing the resulting string; if you need programmatic access to the stack
frames, you can call [[Throwable#getStackTrace()]]
.