本文整理汇总了Java中rx.plugins.RxJavaErrorHandler类的典型用法代码示例。如果您正苦于以下问题:Java RxJavaErrorHandler类的具体用法?Java RxJavaErrorHandler怎么用?Java RxJavaErrorHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxJavaErrorHandler类属于rx.plugins包,在下文中一共展示了RxJavaErrorHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: throwingInOnCompleteDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void throwingInOnCompleteDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
});
RecordingSubscriber<Void> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.completable().unsafeSubscribe(new ForwardingCompletableObserver(observer) {
@Override public void onCompleted() {
throw e;
}
});
assertThat(pluginRef.get()).isSameAs(e);
}
示例2: bodyThrowingInOnCompleteDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void bodyThrowingInOnCompleteDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
});
RecordingSubscriber<String> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.body().unsafeSubscribe(new ForwardingSubscriber<String>(observer) {
@Override public void onCompleted() {
throw e;
}
});
observer.assertAnyValue();
assertThat(pluginRef.get()).isSameAs(e);
}
示例3: responseThrowingInOnCompleteDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void responseThrowingInOnCompleteDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
});
RecordingSubscriber<Response<String>> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.response().unsafeSubscribe(new ForwardingSubscriber<Response<String>>(observer) {
@Override public void onCompleted() {
throw e;
}
});
observer.assertAnyValue();
assertThat(pluginRef.get()).isSameAs(e);
}
示例4: resultThrowingInOnCompletedDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void resultThrowingInOnCompletedDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
});
RecordingSubscriber<Result<String>> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.result().unsafeSubscribe(new ForwardingSubscriber<Result<String>>(observer) {
@Override public void onCompleted() {
throw e;
}
});
observer.assertAnyValue();
assertThat(pluginRef.get()).isSameAs(e);
}
示例5: throwingInOnCompleteDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void throwingInOnCompleteDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (throwable instanceof OnCompletedFailedException) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
}
});
RecordingSubscriber<Void> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.completable().subscribe(new ForwardingCompletableObserver(observer) {
@Override public void onCompleted() {
throw e;
}
});
assertThat(pluginRef.get().getCause()).isSameAs(e);
}
示例6: bodyThrowingInOnSuccessDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void bodyThrowingInOnSuccessDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
});
RecordingSubscriber<String> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.body().subscribe(new ForwardingObserver<String>(observer) {
@Override public void onSuccess(String value) {
throw e;
}
});
assertThat(pluginRef.get()).isSameAs(e);
}
示例7: responseThrowingInOnSuccessDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void responseThrowingInOnSuccessDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
});
RecordingSubscriber<Response<String>> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.response().subscribe(new ForwardingObserver<Response<String>>(observer) {
@Override public void onSuccess(Response<String> value) {
throw e;
}
});
assertThat(pluginRef.get()).isSameAs(e);
}
示例8: resultThrowingInOnSuccessDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void resultThrowingInOnSuccessDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
});
RecordingSubscriber<Result<String>> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.result().subscribe(new ForwardingObserver<Result<String>>(observer) {
@Override public void onSuccess(Result<String> value) {
throw e;
}
});
assertThat(pluginRef.get()).isSameAs(e);
}
示例9: bodyThrowingInOnCompleteDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void bodyThrowingInOnCompleteDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (throwable instanceof OnCompletedFailedException) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
}
});
RecordingSubscriber<String> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.body().subscribe(new ForwardingSubscriber<String>(observer) {
@Override public void onCompleted() {
throw e;
}
});
observer.assertAnyValue();
assertThat(pluginRef.get().getCause()).isSameAs(e);
}
示例10: responseThrowingInOnCompleteDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void responseThrowingInOnCompleteDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (throwable instanceof OnCompletedFailedException) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
}
});
RecordingSubscriber<Response<String>> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.response().subscribe(new ForwardingSubscriber<Response<String>>(observer) {
@Override public void onCompleted() {
throw e;
}
});
observer.assertAnyValue();
assertThat(pluginRef.get().getCause()).isSameAs(e);
}
示例11: resultThrowingInOnCompletedDeliveredToPlugin
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Test public void resultThrowingInOnCompletedDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (throwable instanceof OnCompletedFailedException) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
}
}
});
RecordingSubscriber<Result<String>> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.result().subscribe(new ForwardingSubscriber<Result<String>>(observer) {
@Override public void onCompleted() {
throw e;
}
});
observer.assertAnyValue();
assertThat(pluginRef.get().getCause()).isSameAs(e);
}
示例12: onCreate
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override
public void handleError(Throwable e) {
try {
Log.e("CRASH", "Unhandled exception", e);
} catch (Throwable t) {
//Required by error handler
}
}
});
}
}
示例13: SleuthRxJavaSchedulersHook
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
SleuthRxJavaSchedulersHook(Tracer tracer, TraceKeys traceKeys,
List<String> threadsToSample) {
this.tracer = tracer;
this.traceKeys = traceKeys;
this.threadsToSample = threadsToSample;
try {
this.delegate = RxJavaPlugins.getInstance().getSchedulersHook();
if (this.delegate instanceof SleuthRxJavaSchedulersHook) {
return;
}
RxJavaErrorHandler errorHandler = RxJavaPlugins.getInstance().getErrorHandler();
RxJavaObservableExecutionHook observableExecutionHook
= RxJavaPlugins.getInstance().getObservableExecutionHook();
logCurrentStateOfRxJavaPlugins(errorHandler, observableExecutionHook);
RxJavaPlugins.getInstance().reset();
RxJavaPlugins.getInstance().registerSchedulersHook(this);
RxJavaPlugins.getInstance().registerErrorHandler(errorHandler);
RxJavaPlugins.getInstance().registerObservableExecutionHook(observableExecutionHook);
} catch (Exception e) {
log.error("Failed to register Sleuth RxJava SchedulersHook", e);
}
}
示例14: API
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
private API(String baseUrl, String token) {
this.token = token;
this.baseUrl = baseUrl;
RestAdapter restAdapter = buildRestAdapter(baseUrl, token);
endpoints = restAdapter.create(Endpoints.class);
if(RxJavaPlugins.getInstance().getErrorHandler() == null)
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override
public void handleError(Throwable e) {
Log.w(RxJavaErrorHandler.class.getSimpleName(), e);
super.handleError(e);
}
});
}
示例15: initializeRx
import rx.plugins.RxJavaErrorHandler; //导入依赖的package包/类
public static void initializeRx(final Plugin plugin) {
// Register global error handler
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override
public void handleError(Throwable e) {
plugin.getLogger().log(Level.SEVERE, "Unhandled exception in observable", e);
}
});
// Register global schedulers
RxJavaPlugins.getInstance().registerDefaultSchedulers(new RxJavaDefaultSchedulers() {
@Override
public Scheduler getComputationScheduler() {
return BukkitRxScheduler.forPlugin(plugin, BukkitRxScheduler.ConcurrencyMode.SYNCHRONOUS);
}
@Override
public Scheduler getIOScheduler() {
return BukkitRxScheduler.forPlugin(plugin, BukkitRxScheduler.ConcurrencyMode.ASYNCHRONOUS);
}
@Override
public Scheduler getNewThreadScheduler() {
return BukkitRxScheduler.forPlugin(plugin, BukkitRxScheduler.ConcurrencyMode.ASYNCHRONOUS);
}
});
}