File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
src/main/java/rx/internal/schedulers Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 1515 */
1616package rx .internal .schedulers ;
1717
18+ import java .util .concurrent .atomic .AtomicIntegerFieldUpdater ;
19+
1820import rx .Subscription ;
21+ import rx .exceptions .OnErrorNotImplementedException ;
1922import rx .functions .Action0 ;
23+ import rx .plugins .RxJavaPlugins ;
2024import rx .subscriptions .CompositeSubscription ;
2125
22- import java .util .concurrent .atomic .AtomicIntegerFieldUpdater ;
23-
2426/**
25- * A {@code Runnable} that executes an {@code Action0} and can be cancelled. The analogue is the
27+ * A {@code Runnable} that executes an {@code Action0} and can be cancelled. The analog is the
2628 * {@code Subscriber} in respect of an {@code Observer}.
2729 */
2830public final class ScheduledAction implements Runnable , Subscription {
@@ -41,6 +43,16 @@ public ScheduledAction(Action0 action) {
4143 public void run () {
4244 try {
4345 action .call ();
46+ } catch (Throwable e ) {
47+ // nothing to do but print a System error as this is fatal and there is nowhere else to throw this
48+ IllegalStateException ie = null ;
49+ if (e instanceof OnErrorNotImplementedException ) {
50+ ie = new IllegalStateException ("Exception thrown on Scheduler.Worker thread. Add `onError` handling." , e );
51+ } else {
52+ ie = new IllegalStateException ("Fatal Exception thrown on Scheduler.Worker thread." , e );
53+ }
54+ ie .printStackTrace ();
55+ RxJavaPlugins .getInstance ().getErrorHandler ().handleError (ie );
4456 } finally {
4557 unsubscribe ();
4658 }
You can’t perform that action at this time.
0 commit comments