Skip to content

Commit 87e308a

Browse files
Add Error propagation now that we use Throwable.
1 parent 0531b8b commit 87e308a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

rxjava-core/src/main/java/rx/util/Exceptions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@ private Exceptions() {
2121
}
2222

2323
public static RuntimeException propagate(Throwable t) {
24+
/**
25+
* The return type of RuntimeException is a trick for code to be like this:
26+
*
27+
* throw Exceptions.propagate(e);
28+
*
29+
* Even though nothing will return and throw via that 'throw', it allows the code to look like it
30+
* so it's easy to read and understand that it will always result in a throw.
31+
*/
2432
if (t instanceof RuntimeException) {
2533
throw (RuntimeException) t;
34+
} else if (t instanceof Error) {
35+
throw (Error) t;
2636
} else {
2737
throw new RuntimeException(t);
2838
}

0 commit comments

Comments
 (0)