FabianTerhorst / ApiClient

A easy to use api client that combines the power of Retrofit, Realm, Gson, Rxjava and Retrolambda in a easy to use library for Java and Android
Apache License 2.0
96 stars 16 forks source link

ApiClient is crashed on request while host is unreachable. #5

Closed Scit closed 8 years ago

Scit commented 8 years ago

ApiClient is crashed on requests while the host is unreachable. The same will occur when device would has no internet connection. Is it the expected behavior?

     Caused by: java.net.ConnectException: Failed to connect to /test-host:8000
            at okhttp3.internal.io.RealConnection.connectSocket(RealConnection.java:142)
            at okhttp3.internal.io.RealConnection.connect(RealConnection.java:111)
            at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:188)
            at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:127)
            at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
            at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:289)
            at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
            at okhttp3.RealCall.getResponse(RealCall.java:240)
            at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
            at io.fabianterhorst.apiclient.ApiClient.lambda$new$4(ApiClient.java:35)
            at io.fabianterhorst.apiclient.ApiClient.access$lambda$0(ApiClient.java)
            at io.fabianterhorst.apiclient.ApiClient$$Lambda$1.intercept(Unknown Source)
            at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
            at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
            at okhttp3.RealCall.execute(RealCall.java:57)
            at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
            at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:144)
            at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:125)
            at rx.Observable$2.call(Observable.java:233)
            at rx.Observable$2.call(Observable.java:225)
            at rx.Observable$2.call(Observable.java:233)
            at rx.Observable$2.call(Observable.java:225)
            at rx.Observable.unsafeSubscribe(Observable.java:8644)
            at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
            at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:150)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:264)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Threa
FabianTerhorst commented 8 years ago

@Scit yes it is, you can catch this with using the Rxjava onError().