MCPcopy
hub / github.com/google/guava / throwIfUnchecked

Method throwIfUnchecked

guava/src/com/google/common/base/Throwables.java:129–137  ·  view source on GitHub ↗

Throws throwable if it is a RuntimeException or Error. Example usage: for (Foo foo : foos) { try { foo.bar(); } catch (RuntimeException | Error t) { failure = t; } } if (failure != null) { throwIfUnchecked(failure); throw new AssertionError(failure);

(Throwable throwable)

Source from the content-addressed store, hash-verified

127 * @since 20.0
128 */
129 public static void throwIfUnchecked(Throwable throwable) {
130 checkNotNull(throwable);
131 if (throwable instanceof RuntimeException) {
132 throw (RuntimeException) throwable;
133 }
134 if (throwable instanceof Error) {
135 throw (Error) throwable;
136 }
137 }
138
139 /**
140 * Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@link

Callers 15

propagateIfPossibleMethod · 0.95
propagateMethod · 0.95
getUsernameMethod · 0.45
rethrowMethod · 0.45
closeMethod · 0.45
wrapTaskMethod · 0.45
closeMethod · 0.45

Calls 1

checkNotNullMethod · 0.45

Tested by 11

closeMethod · 0.36
invokeGeneratorMethodMethod · 0.36
testNullsMethod · 0.36
testEqualsMethod · 0.36
runTearDownMethod · 0.36
runFinalizationMethod · 0.36