MCPcopy Create free account
hub / github.com/antlr/codebuff / throwIfInstanceOf

Method throwIfInstanceOf

output/java_guava/1.4.19/Throwables.java:73–80  ·  view source on GitHub ↗

Throws throwable if it is an instance of declaredType. Example usage: for (Foo foo : foos) { try { foo.bar(); } catch (BarException | RuntimeException | Error t) { failure = t; } } if (failure != null) { throwIfInstanceOf(failure, BarException.class); throwIf

(Throwable throwable, Class<X> declaredType)

Source from the content-addressed store, hash-verified

71
72
73 @GwtIncompatible // Class.cast, Class.isInstance
74 public static <X extends Throwable> void throwIfInstanceOf(Throwable throwable, Class<X> declaredType)
75 throws X {
76 checkNotNull(throwable);
77 if (declaredType.isInstance(throwable)) {
78 throw declaredType.cast(throwable);
79 }
80 }
81
82 /**
83 * Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@code

Callers 1

propagateIfInstanceOfMethod · 0.95

Calls 2

checkNotNullMethod · 0.45
castMethod · 0.45

Tested by

no test coverage detected