question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ktor client cannot catch offline exceptions (Kotlin Multiplatform)

See original GitHub issue

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]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
joselufocommented, Jun 15, 2020

@e5l when it’s going to be released the fix?

4reactions
tonilopezmrcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client: Handle network exceptions in the commonMain module
Hi everyone,. using ktor-client in a Kotlin multiplatform project, how can you deal/detect network errors? Detecting status code or serialization issues can be ......
Read more >
Handle response http code and exceptions with Ktor
I've tested your scenario with this sample class (got and modified from official ktor github rep) and I can hit all breakpoints where...
Read more >
WhatsNew 2.1 | Ktor Framework
Ktor client native ignores try/catch: "kotlin.coroutines.cancellation.CancellationException: StandaloneCoroutine was cancelled".
Read more >
Handle Response Http Code And Exceptions With Ktor
In this tutorial, you'll learn how to use Kotlin Multiplatform and build an ... Ktor client cannot catch offline exceptions (Kotlin Multiplatform) #1165....
Read more >
Shared Library in Kotlin Multiplatform - Karumi Blog
Check out the first steps into Kotlin Multiplatform, ... are still present like issue #1165: Ktor client cannot catch offline exceptions and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found