mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add simple constructor for JSError (#39415)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39415 Add a simple constructor for `JSError` which does not accept a `jsi::Runtime` and cannot call back into JSI. This guarantees that the constructor cannot recursively invoke itself, leading to stack overflows. Changelog: [Internal] Reviewed By: avp Differential Revision: D48796703 fbshipit-source-id: 1c134e8a59ff54be64a5da901e548436d512c21d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dce7242ab6
commit
9faf256949
@@ -450,6 +450,12 @@ JSError::JSError(std::string what, Runtime& rt, Value&& value)
|
||||
setValue(rt, std::move(value));
|
||||
}
|
||||
|
||||
JSError::JSError(Value&& value, std::string message, std::string stack)
|
||||
: JSIException(message + "\n\n" + stack),
|
||||
value_(std::make_shared<Value>(std::move(value))),
|
||||
message_(std::move(message)),
|
||||
stack_(std::move(stack)) {}
|
||||
|
||||
void JSError::setValue(Runtime& rt, Value&& value) {
|
||||
value_ = std::make_shared<Value>(std::move(value));
|
||||
|
||||
|
||||
@@ -1468,6 +1468,11 @@ class JSI_EXPORT JSError : public JSIException {
|
||||
/// but necessary to avoid ambiguity with the above.
|
||||
JSError(std::string what, Runtime& rt, Value&& value);
|
||||
|
||||
/// Creates a JSError referring to the provided value, message and stack. This
|
||||
/// constructor does not take a Runtime parameter, and therefore cannot result
|
||||
/// in recursively invoking the JSError constructor.
|
||||
JSError(Value&& value, std::string message, std::string stack);
|
||||
|
||||
JSError(const JSError&) = default;
|
||||
|
||||
virtual ~JSError();
|
||||
|
||||
Reference in New Issue
Block a user