https://github.com/jessyancoding/rxerrorhandler
🗑 Error Handle Of Rxjava
https://github.com/jessyancoding/rxerrorhandler
arms mvparms rxjava rxjava-library
Last synced: 3 months ago
JSON representation
🗑 Error Handle Of Rxjava
- Host: GitHub
- URL: https://github.com/jessyancoding/rxerrorhandler
- Owner: JessYanCoding
- License: apache-2.0
- Created: 2016-09-02T07:08:51.000Z (almost 9 years ago)
- Default Branch: 2.x
- Last Pushed: 2023-09-01T16:24:06.000Z (almost 2 years ago)
- Last Synced: 2025-03-20T07:04:52.902Z (3 months ago)
- Topics: arms, mvparms, rxjava, rxjava-library
- Language: Java
- Homepage:
- Size: 302 KB
- Stars: 164
- Watchers: 5
- Forks: 24
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RxErrorHandler
[  ](https://bintray.com/jessyancoding/maven/rxerrorhandler/2.1.1/link)
[  ](https://travis-ci.org/JessYanCoding/RxErrorHandler)
[  ](https://developer.android.com/about/versions/android-2.3.html)
[  ](http://www.apache.org/licenses/LICENSE-2.0)
[  ](https://www.jianshu.com/u/1d0c0bc634db)
[  ](https://shang.qq.com/wpa/qunwpa?idkey=7e59e59145e6c7c68932ace10f52790636451f01d1ecadb6a652b1df234df753)## Error Handle Of Rxjava
## Download
``` gradle
implementation 'me.jessyan:rxerrorhandler:2.1.1' //rxjava2implementation 'me.jessyan:rxerrorhandler:1.0.1' //rxjava1
```## Initialization
``` java
RxErrorHandler rxErrorHandler = RxErrorHandler
.builder()
.with(this)
.responseErrorListener(new ResponseErrorListener() {
@Override
          public void handleResponseError(Context context, Throwable t) {
if (t instanceof UnknownHostException) {
//do something ...
} else if (t instanceof SocketTimeoutException) {
//do something ...
} else {
//handle other Exception ...
}
Log.w(TAG, "Error handle");
}
}).build();
```## Usage
``` java
Observable
.error(new Exception("Error"))
.retryWhen(new RetryWithDelay(3, 2))//retry(http connect timeout)
.subscribe(new ErrorHandleSubscriber(rxErrorHandler) {
@Override
public void onNext(Object o) {}
});
//Backpressure
Flowable
.error(new Exception("Error"))
.retryWhen(new RetryWithDelayOfFlowable(3, 2))//retry(http connect timeout)
.subscribe(new ErrorHandleSubscriberOfFlowable(rxErrorHandler) {
@Override
public void onNext(Object o) {}
});
```## About Me
* **Email**:
* **Home**:
* **掘金**:
* **简书**:## License
```
Copyright 2016, jessyan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```