File tree 1 file changed +15
-3
lines changed
src/main/java/rx/internal/schedulers 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package rx .internal .schedulers ;
17
17
18
+ import java .util .concurrent .atomic .AtomicIntegerFieldUpdater ;
19
+
18
20
import rx .Subscription ;
21
+ import rx .exceptions .OnErrorNotImplementedException ;
19
22
import rx .functions .Action0 ;
23
+ import rx .plugins .RxJavaPlugins ;
20
24
import rx .subscriptions .CompositeSubscription ;
21
25
22
- import java .util .concurrent .atomic .AtomicIntegerFieldUpdater ;
23
-
24
26
/**
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
26
28
* {@code Subscriber} in respect of an {@code Observer}.
27
29
*/
28
30
public final class ScheduledAction implements Runnable , Subscription {
@@ -41,6 +43,16 @@ public ScheduledAction(Action0 action) {
41
43
public void run () {
42
44
try {
43
45
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 );
44
56
} finally {
45
57
unsubscribe ();
46
58
}
You can’t perform that action at this time.
0 commit comments