Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ktor client cannot catch offline exceptions (Kotlin Multiplatform) #1165

Open
LiewJunTung opened this issue Jun 3, 2019 · 5 comments

Comments

@LiewJunTung
Copy link

commented Jun 3, 2019

Ktor Version

1.2.0

Ktor Engine Used(client or server and name)

IOS Client

JVM Version, Operating System and Relevant Context

iOS - Airplane mode

Feedback

Tried to catch offline mode exception in case the internet connection is dropped. The errors showed up in the logs but cannot be caught in Multiplatform common project. Haven't tried on Android yet.

2019-06-03 16:02:17.432609+0800 XApp[1558:1117673] Task <449DDD76-DA3D-42B4-9CA4-ECEA0B218850>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x282e59d40 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <449DDD76-DA3D-42B4-9CA4-ECEA0B218850>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <449DDD76-DA3D-42B4-9CA4-ECEA0B218850>.<1>"
), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://localhost/?page=1&ordering=modified&search=, NSErrorFailingURLKey=https://localhost/?page=1&ordering=modified&search=, _kCFStreamErrorDomainKey=1} [-1009]

@LiewJunTung LiewJunTung changed the title Ktor client cannot catch exception (Kotlin Multiplatform) Ktor client cannot catch offline exceptions (Kotlin Multiplatform) Jun 3, 2019

@e5l e5l self-assigned this Jun 3, 2019

@e5l e5l added the problem label Jun 3, 2019

@e5l e5l added this to the 1.2.2 milestone Jun 3, 2019

@tonilopezmr

This comment has been minimized.

Copy link

commented Jun 13, 2019

I have the same problem, @LiewJunTung how did you catch this exception?

In Android is working fine, but in IOS crashes, seems a problem of IosClientEngine and the delegate protocol.

@e5l e5l modified the milestones: 1.2.2, 1.3.0 Jun 20, 2019

@LiewJunTung

This comment has been minimized.

Copy link
Author

commented Jun 25, 2019

@tonilopezmr for now I'm not handling it. And will wait for the fix by @e5l. :)

@flaquir4

This comment has been minimized.

Copy link

commented Jul 16, 2019

I had the same problem. But I've solved it by catching a Throwable instead of an Exception in the try/catch block.

Hope it helps.

@tonilopezmr

This comment has been minimized.

Copy link

commented Jul 16, 2019

I think I was catching it with Throwable as well :think: I'll try another time

@svendroid

This comment has been minimized.

Copy link

commented Jul 18, 2019

I am experiencing the same problem, catching Throwable instead of Exception did not work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.