Skip to content

Commit

Permalink
Remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Jan 9, 2024
1 parent 079b630 commit 6033ae2
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
return runtime.global().getPropertyAsFunction(runtime, "Error").call(runtime, message);
}

static jsi::Value createJSRuntimeError(jsi::Runtime &runtime, const std::string &message, jsi::Object &options)
{
return runtime.global().getPropertyAsFunction(runtime, "Error").call(runtime, message, options);
}

/**
* Creates JSError with current JS runtime and NSException stack trace.
*/
Expand All @@ -221,15 +216,10 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
*/
static jsi::Value convertJSErrorDetailsToJSRuntimeError(jsi::Runtime &runtime, NSDictionary *jsErrorDetails)
{
// From JS documentation:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error#cause an
// Error can be created with `new Error(message, option);`. the `option` param is a JS object with the
// `cause` property. Create a valid `option` object
jsi::Object jsErrorOptions = jsi::Object(runtime);
jsErrorOptions.setProperty(runtime, "cause", convertObjCObjectToJSIValue(runtime, jsErrorDetails));
NSString *message = jsErrorDetails[@"message"];

auto jsError = createJSRuntimeError(runtime, [message UTF8String], jsErrorOptions);
auto jsError = createJSRuntimeError(runtime, [message UTF8String]);
jsError.asObject(runtime).setProperty(runtime, "cause", convertObjCObjectToJSIValue(runtime, jsErrorDetails));

return jsError;
}
Expand Down

0 comments on commit 6033ae2

Please sign in to comment.