Comments (16)
Have you tried doing what the message suggests, add an onError
hook? You probably subscribed without an error hook, and an error occurred...
from rxandroid.
Added onError
i used this function
public final Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError) {
if (onNext == null) {
throw new IllegalArgumentException("onNext can not be null");
}
if (onError == null) {
throw new IllegalArgumentException("onError can not be null");
}
return subscribe(new Subscriber<T>() {
@Override
public final void onCompleted() {
// do nothing
}
@Override
public final void onError(Throwable e) {
onError.call(e);
}
@Override
public final void onNext(T args) {
onNext.call(args);
}
});
}
from rxandroid.
There is nothing actionable here for me. Can you add more context? What is it you're trying to do?
from rxandroid.
I no reproduce this error, only on Google play crash log.
from rxandroid.
That doesn't help me.
from rxandroid.
@mttkay Sure this error, I use Retrofit, RxJava, RxAndroid on Android, when invoke NoConnectionException, the app crash. please fix.
private class APIErrorHandler implements ErrorHandler {
@Override
public Throwable handleError(RetrofitError cause) {
if (cause.getKind() == Kind.NETWORK) {
if (cause.getCause() instanceof SocketTimeoutException) {
return new ConnectionTimeoutException();
} else {
return new NoConnectionException();
}
}
}
E/AndroidRuntime(22087): Process: com.oxa7.shou, PID: 22087
E/AndroidRuntime(22087): java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. Add `onError` handling.
E/AndroidRuntime(22087): at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:52)
E/AndroidRuntime(22087): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(22087): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(22087): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(22087): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(22087): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(22087): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(22087): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(22087): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime(22087): Caused by: rx.exceptions.OnErrorNotImplementedException
E/AndroidRuntime(22087): at rx.Observable$31.onError(Observable.java:7069)
E/AndroidRuntime(22087): at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:154)
E/AndroidRuntime(22087): at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
E/AndroidRuntime(22087): at rx.android.operators.OperatorConditionalBinding$1.onError(OperatorConditionalBinding.java:66)
E/AndroidRuntime(22087): at rx.internal.operators.NotificationLite.accept(NotificationLite.java:147)
E/AndroidRuntime(22087): at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:177)
E/AndroidRuntime(22087): at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.access$000(OperatorObserveOn.java:65)
E/AndroidRuntime(22087): at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:153)
E/AndroidRuntime(22087): at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:47)
E/AndroidRuntime(22087): ... 8 more
E/AndroidRuntime(22087): Caused by: xxxx.api.BaseAPI$NoConnectionException
E/AndroidRuntime(22087): at xxx.api.BaseAPI$APIErrorHandler.handleError(BaseAPI.java:86)
E/AndroidRuntime(22087): at retrofit.RxSupport$2.run(RxSupport.java:59)
E/AndroidRuntime(22087): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
E/AndroidRuntime(22087): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime(22087): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(22087): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(22087): at retrofit.Platform$Android$2$1.run(Platform.java:142)
E/AndroidRuntime(22087): at java.lang.Thread.run(Thread.java:818)
from rxandroid.
@crossle could you provide the operators related to this bug?
from rxandroid.
Your APIErrorHandler
throws. Think of onError
as your catch. If you throw inside a catch what happens?
from rxandroid.
I use like this
mSubscription = AndroidObservable.bindActivity(Activity.this, xxxAPI.show(id))
.subscribe(new Action1<XX>() {
@Override
public void call(User user) {
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable err) {
Log....
}
});
@hamidp Catch onError
?
from rxandroid.
Where's your APIErrorHandler
referenced?
from rxandroid.
RestAdapter.Builder builder = new RestAdapter.Builder().setEndpoint(API_ROOT)
.setErrorHandler(new APIErrorHandler()).setRequestInterceptor(mRequestInterceptor).setClient(new OkClient(ok));
from rxandroid.
@mttkay please reopen this issue.
@hamidp @zsxwing How about this issue?
from rxandroid.
@JakeWharton Look like Retrofit error.
from rxandroid.
@crossle did you fix it?
from rxandroid.
@luccasmaso No
from rxandroid.
remove the APIErrorHandler and call it like this:
the_observable.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.map(mPojo -> " abc: " + mPojo.whatever())
.subscribe(current -> {
Log.e("Output is", current.toString());
}, throwable -> Log.e("Error", throwable.getMessage()));
I'm using:
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.0.16'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
from rxandroid.
Related Issues (20)
- move from version 2 to version 3 HOT 2
- BUG with gradle 3.6.1 and RxJava and RxAndroid 3.0.0 HOT 2
- RX Android & Release apk HOT 1
- RxAndroid
- HandlerScheduler throws NPE on schedule() in tests HOT 4
- AndroidRuntime: FATAL EXCEPTION -> observeOn(AndroidSchedulers.mainThread()) HOT 5
- Bug or Help Long running observable in background crashes app HOT 1
- [email protected]: Permission denied (publickey). HOT 1
- java.lang.NoSuchMethodError HOT 17
- IllegalAccessError: FlowableDoOnLifecycle: 2.2.3 HOT 1
- docs/content/github/collaborating-with-issues-and-pull-requests/merging-a-pull-request.md
- Gi
- issue with the indirect dependency component reactive-stream License HOT 2
- Does RxAndroid have any plans to release a new version? HOT 1
- Add Sonatype secrets to repo for GitHub Actions usage HOT 9
- RxAndroid 3.0.1 NPE in JVM unit tests HOT 1
- ERROR: Failed to resolve: io.reactivex.rxjava3:rxandroid:3.0.2 HOT 5
- Sms2
- Why the HandlerScheduler class overrides scheduleDirect. It's not more explicit to let the HandlerWorker do the work HOT 4
- Kotlin multiplaform support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxandroid.