Skip to content

Commit

Permalink
Add Error propagation now that we use Throwable.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjchristensen committed Aug 1, 2013
1 parent 0531b8b commit 87e308a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rxjava-core/src/main/java/rx/util/Exceptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ private Exceptions() {
}

public static RuntimeException propagate(Throwable t) {
/**
* The return type of RuntimeException is a trick for code to be like this:
*
* throw Exceptions.propagate(e);
*
* Even though nothing will return and throw via that 'throw', it allows the code to look like it
* so it's easy to read and understand that it will always result in a throw.
*/
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else if (t instanceof Error) {
throw (Error) t;
} else {
throw new RuntimeException(t);
}
Expand Down

0 comments on commit 87e308a

Please sign in to comment.