Zsolt Bencze
10/19/2023, 12:48 PMFunction doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
Any insight on why this happens and what can be done?kpgalligan
10/19/2023, 12:53 PM@Throws
annotation, so Kotlin will just crash rather than trying to send that as an NSError. And, honestly, that's fine. Kotlin has unchecked exceptions everything. Swift is 100% the opposite. You have to be very explicit with exceptions. This is more of a code design issue. If you are expecting an exception there, you should probably catch it and return some type of result optional with either the expected return or an error. Alternatively, you can add @Throws
to that method, and then you'll need to try/catch from Swift, and deal with it that way.@Throws
, basically.Zsolt Bencze
10/19/2023, 12:55 PM@Throws
to the method annotation 🤔 but did not consider catching it from the iOS side. You are likely right though, my background is mostly iOS, so my Android/KMM skills probably are lacking.kpgalligan
10/19/2023, 12:56 PMZsolt Bencze
10/19/2023, 12:56 PMkpgalligan
10/19/2023, 12:56 PM@Throws
. It should just "crash".Zsolt Bencze
10/19/2023, 12:56 PMkpgalligan
10/19/2023, 12:56 PMZsolt Bencze
10/19/2023, 12:56 PMkpgalligan
10/19/2023, 12:57 PMZsolt Bencze
10/19/2023, 12:57 PMkpgalligan
10/19/2023, 12:58 PMZsolt Bencze
10/19/2023, 12:59 PMkpgalligan
10/19/2023, 1:00 PMZsolt Bencze
10/19/2023, 1:00 PMimport Bugsnag
let configuration = BugsnagConfiguration.loadConfig()
let platformNativeComponent = PlatformNativeComponent(bugsnagConfiguration: configuration)
InitializerKt.doInitApp(platformNativeComponent: platformNativeComponent, appDeclaration: { _ in }
and then the commonMain
would initialize (this is the doInitApp
) and call:
initializeAndStartErrorReporting(platformNativeComponent)
which is an expect/actual,
and in the iOSMain
actual fun initializeAndStartErrorReporting(platformNativeComponent: PlatformNativeComponent) {
startBugsnag(platformNativeComponent.bugsnagConfiguration)
}
where the import for startBugsnag
is import co.touchlab.kermit.bugsnag.startBugsnag
kpgalligan
10/19/2023, 1:10 PMZsolt Bencze
10/19/2023, 1:11 PM"co.touchlab:kermit-gradle-plugin:1.2.2"
"co.touchlab:kermit:1.2.2"
id("co.touchlab.crashkios.bugsnaglink") version "0.8.2"
kpgalligan
10/19/2023, 1:15 PMZsolt Bencze
10/19/2023, 1:16 PMBugsnag (6.26.2)
kpgalligan
10/19/2023, 1:21 PMid("co.touchlab.crashkios.bugsnaglink") version "0.8.2"
only handles that for the framework build, not the test build.Zsolt Bencze
10/19/2023, 1:23 PM