fix: Throw JS errors if JSI <-> JNI conversion failed (#324)
This commit is contained in:
parent
25ab5382c1
commit
1c32726ef6
@ -74,14 +74,14 @@ jobject JSIJNIConversion::convertJSIValueToJNIObject(jsi::Runtime &runtime, cons
|
|||||||
return hostObject->frame.get();
|
return hostObject->frame.get();
|
||||||
} else {
|
} else {
|
||||||
// it's different kind of HostObject. We don't support it.
|
// it's different kind of HostObject. We don't support it.
|
||||||
return nullptr;
|
throw std::runtime_error("Received an unknown HostObject! Cannot convert to a JNI value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (object.isFunction(runtime)) {
|
} else if (object.isFunction(runtime)) {
|
||||||
// jsi::Function
|
// jsi::Function
|
||||||
|
|
||||||
// TODO: Convert Function to Callback
|
// TODO: Convert Function to Callback
|
||||||
return nullptr;
|
throw std::runtime_error("Cannot convert a JS Function to a JNI value (yet)!");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// jsi::Object
|
// jsi::Object
|
||||||
@ -89,13 +89,15 @@ jobject JSIJNIConversion::convertJSIValueToJNIObject(jsi::Runtime &runtime, cons
|
|||||||
auto dynamic = jsi::dynamicFromValue(runtime, value);
|
auto dynamic = jsi::dynamicFromValue(runtime, value);
|
||||||
auto map = react::ReadableNativeMap::createWithContents(std::move(dynamic));
|
auto map = react::ReadableNativeMap::createWithContents(std::move(dynamic));
|
||||||
return map.release();
|
return map.release();
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// unknown jsi type!
|
// unknown jsi type!
|
||||||
|
|
||||||
auto stringRepresentation = value.toString(runtime).utf8(runtime);
|
auto stringRepresentation = value.toString(runtime).utf8(runtime);
|
||||||
auto message = "Received unknown JSI value! (" + stringRepresentation + ") Cannot convert to JNI Object.";
|
auto message = "Received unknown JSI value! (" + stringRepresentation + ") Cannot convert to a JNI value.";
|
||||||
__android_log_write(ANDROID_LOG_ERROR, "VisionCamera", message.c_str());
|
throw std::runtime_error(message);
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ Similar to a TurboModule, the Frame Processor Plugin Registry API automatically
|
|||||||
| `number` | `NSNumber*` (double) | `Double` |
|
| `number` | `NSNumber*` (double) | `Double` |
|
||||||
| `boolean` | `NSNumber*` (boolean) | `Boolean` |
|
| `boolean` | `NSNumber*` (boolean) | `Boolean` |
|
||||||
| `string` | `NSString*` | `String` |
|
| `string` | `NSString*` | `String` |
|
||||||
| `[]` | `NSArray*` | `ArrayList<E>` |
|
| `[]` | `NSArray*` | `ReadableNativeArray` |
|
||||||
| `{}` | `NSDictionary*` | `HashMap<K, V>` |
|
| `{}` | `NSDictionary*` | `ReadableNativeMap` |
|
||||||
| `undefined` / `null` | `nil` | `null` |
|
| `undefined` / `null` | `nil` | `null` |
|
||||||
| `(any, any) => void` | [`RCTResponseSenderBlock`][4] | `(Object, Object) -> void` |
|
| `(any, any) => void` | [`RCTResponseSenderBlock`][4] | `(Object, Object) -> void` |
|
||||||
| [`Frame`][1] | [`Frame*`][2] | [`ImageProxy`][3] |
|
| [`Frame`][1] | [`Frame*`][2] | [`ImageProxy`][3] |
|
||||||
|
Loading…
Reference in New Issue
Block a user