Skip to content

Remove Kotlin error name and stacktrace from js error.message #1014

@Phecda

Description

@Phecda

Feature Request/Enhancement

Hello again!
I find that if I throw a Error in Kotlin and catch it in js, the js error.message has the name and stacktrace of that kotlin error, which is not same as Swift.

It would be better to remove these useless info to keep error.message clean.

override fun doSomething(): Promise<String?> {
    return Promise.rejected(Error("Failed"))
}

and in js log its message

try {
  await doSomething();
} catch (error) {
  console.log(error.message);
}

and the log looks like

java.lang.Error: Failed
	at com.margelo.nitro.deviceinfo.DeviceInfo.doSomething(DeviceInfo.kt:120)
	at com.facebook.jni.NativeRunnable.run(Native Method)
	at android.os.Handler.handleCallback(Handler.java:958)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.kt:21)
	at android.os.Looper.loopOnce(Looper.java:222)
	at android.os.Looper.loop(Looper.java:314)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$Companion.startNewBackgroundThread$lambda$1(MessageQueueThreadImpl.kt:175)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$Companion.$r8$lambda$ldnZnqelhYFctGaUKkOKYj5rxo4(Unknown Source:0)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$Companion$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
	at java.lang.Thread.run(Thread.java:1012)

Are there any existing workarounds?

No response

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestkotlinIssue regarding the Kotlin part of Nitro/Nitrogen

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions