diff --git a/jvm/hermes/src/main/kotlin/com/intuit/playerui/jsi/serialization/encoding/JSIDecoders.kt b/jvm/hermes/src/main/kotlin/com/intuit/playerui/jsi/serialization/encoding/JSIDecoders.kt index abdee5f0a..8e80bcef6 100644 --- a/jvm/hermes/src/main/kotlin/com/intuit/playerui/jsi/serialization/encoding/JSIDecoders.kt +++ b/jvm/hermes/src/main/kotlin/com/intuit/playerui/jsi/serialization/encoding/JSIDecoders.kt @@ -1,5 +1,6 @@ package com.intuit.playerui.jsi.serialization.encoding +import com.facebook.jni.CppException import com.intuit.playerui.core.bridge.serialization.encoding.AbstractRuntimeArrayListDecoder import com.intuit.playerui.core.bridge.serialization.encoding.AbstractRuntimeObjectClassDecoder import com.intuit.playerui.core.bridge.serialization.encoding.AbstractRuntimeObjectMapDecoder @@ -51,9 +52,12 @@ internal sealed class AbstractJSIValueDecoder( } } override fun decodeFunction(returnTypeSerializer: KSerializer) = runtime.evaluateInJSThreadBlocking { - // TODO: Probably make sure our decoders wrap up underlying cpp exceptions - // TODO: Not sure the function is the correct thisVal -- maybe value? - currentValue.asObject(runtime).asFunction(runtime).toInvokable(format, value.asObject(runtime), returnTypeSerializer) ?: error("Unable to decode JSI function using return type serializer ${returnTypeSerializer.descriptor}") + try { + currentValue.asObject(runtime).asFunction(runtime) + .toInvokable(format, currentValue.asObject(runtime), returnTypeSerializer) + } catch (exception: CppException) { + error("Unable to decode JSI function using return type serializer ${returnTypeSerializer.descriptor}", exception) + } } }