/** * Called when an undeliverable error occurs. * @param error the error to report */ public static void onError(@NonNull Throwable error) { Consumer<? super Throwable> f = errorHandler; if (error == null) { error = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources."); } else { if (!isBug(error)) { error = new UndeliverableException(error); } } if (f != null) { try { f.accept(error); return; } catch (Throwable e) { // Exceptions.throwIfFatal(e); TODO decide e.printStackTrace(); // NOPMD uncaught(e); } } error.printStackTrace(); // NOPMD uncaught(error); }
/** * Called when an undeliverable error occurs. * @param error the error to report */ public static void onError(@NonNull Throwable error) { Consumer<? super Throwable> f = errorHandler; if (error == null) { error = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources."); } else { if (!isBug(error)) { error = new UndeliverableException(error); } } if (f != null) { try { f.accept(error); return; } catch (Throwable e) { // Exceptions.throwIfFatal(e); TODO decide e.printStackTrace(); // NOPMD uncaught(e); } } error.printStackTrace(); // NOPMD uncaught(error); }
/** * Called when an undeliverable error occurs. * @param error the error to report */ public static void onError(@NonNull Throwable error) { Consumer<? super Throwable> f = errorHandler; if (error == null) { error = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources."); } else { if (!isBug(error)) { error = new UndeliverableException(error); } } if (f != null) { try { f.accept(error); return; } catch (Throwable e) { // Exceptions.throwIfFatal(e); TODO decide e.printStackTrace(); // NOPMD uncaught(e); } } error.printStackTrace(); // NOPMD uncaught(error); }
@Test public void isBug() { assertFalse(RxJavaCommonPlugins.isBug(new RuntimeException())); assertFalse(RxJavaCommonPlugins.isBug(new IOException())); assertFalse(RxJavaCommonPlugins.isBug(new InterruptedException())); assertFalse(RxJavaCommonPlugins.isBug(new InterruptedIOException())); assertTrue(RxJavaCommonPlugins.isBug(new NullPointerException())); assertTrue(RxJavaCommonPlugins.isBug(new IllegalArgumentException())); assertTrue(RxJavaCommonPlugins.isBug(new IllegalStateException())); assertTrue(RxJavaCommonPlugins.isBug(new MissingBackpressureException())); assertTrue(RxJavaCommonPlugins.isBug(new ProtocolViolationException(""))); assertTrue(RxJavaCommonPlugins.isBug(new UndeliverableException(new TestException()))); assertTrue(RxJavaCommonPlugins.isBug(new CompositeException(new TestException()))); assertTrue(RxJavaCommonPlugins.isBug(new OnErrorNotImplementedException(new TestException()))); } }