Skip to content

Commit

Permalink
Also report non-fatal non-warning errors
Browse files Browse the repository at this point in the history
Summary:
Just porting over the logic after D28815228.

Changelog: [Internal]

Reviewed By: mlord93

Differential Revision: D66563226
  • Loading branch information
RSNara authored and facebook-github-bot committed Dec 4, 2024
1 parent 734730d commit 9d18556
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ bool isLooselyNull(const jsi::Value& value) {
return value.isNull() || value.isUndefined();
}

bool isEmptyString(jsi::Runtime& runtime, const jsi::Value& value) {
bool isEqualTo(
jsi::Runtime& runtime,
const jsi::Value& value,
std::string str) {
return jsi::Value::strictEquals(
runtime, value, jsi::String::createFromUtf8(runtime, ""));
runtime, value, jsi::String::createFromUtf8(runtime, str));
}

std::string stringifyToCpp(jsi::Runtime& runtime, const jsi::Value& value) {
Expand Down Expand Up @@ -265,7 +268,7 @@ void JsErrorHandler::handleErrorWithCppPipeline(
}

auto nameValue = errorObj.getProperty(runtime, "name");
auto name = (isLooselyNull(nameValue) || isEmptyString(runtime, nameValue))
auto name = (isLooselyNull(nameValue) || isEqualTo(runtime, nameValue, ""))
? std::nullopt
: std::optional(stringifyToCpp(runtime, nameValue));

Expand Down Expand Up @@ -383,14 +386,19 @@ void JsErrorHandler::handleErrorWithCppPipeline(
return;
}

if (isFatal) {
if (_hasHandledFatalError) {
return;
auto errorType = errorObj.getProperty(runtime, "type");
auto isWarn = isEqualTo(runtime, errorType, "warn");

if (isFatal || !isWarn) {
if (isFatal) {
if (_hasHandledFatalError) {
return;
}
_hasHandledFatalError = true;
}
_hasHandledFatalError = true;
}

_onJsError(runtime, parsedError);
_onJsError(runtime, parsedError);
}
}

void JsErrorHandler::registerErrorListener(
Expand Down

0 comments on commit 9d18556

Please sign in to comment.