Refactor: RuntimeScheduler: Delete ErrorUtils.h (#43953)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43953

RuntimeScheduler's ErrorUtils.h is redundant.

Let's just remove it.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D55547905

fbshipit-source-id: 5263c9fca8ae32bbfc672f0e16b79ee177cdd421
This commit is contained in:
Ramanpreet Nara
2024-06-18 14:41:09 +02:00
committed by Thibault Malbranche
parent 37b33c34ba
commit 487c8489f1
4 changed files with 4 additions and 40 deletions
@@ -1,34 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <jsi/jsi.h>
namespace facebook::react {
inline static void handleFatalError(
jsi::Runtime& runtime,
const jsi::JSError& error) {
auto reportFatalError = "reportFatalError";
auto errorUtils = runtime.global().getProperty(runtime, "ErrorUtils");
if (errorUtils.isUndefined() || !errorUtils.isObject() ||
!errorUtils.getObject(runtime).hasProperty(runtime, reportFatalError)) {
// ErrorUtils was not set up. This probably means the bundle didn't
// load properly.
throw jsi::JSError(
runtime,
"ErrorUtils is not set up properly. Something probably went wrong trying to load the JS bundle. Trying to report error " +
error.getMessage(),
error.getStack());
}
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(
runtime, reportFatalError);
func.call(runtime, error.value());
}
} // namespace facebook::react
@@ -13,7 +13,6 @@
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/debug/SystraceSection.h>
#include <utility>
#include "ErrorUtils.h"
namespace facebook::react {
@@ -8,9 +8,9 @@
#include "RuntimeScheduler_Legacy.h"
#include "SchedulerPriorityUtils.h"
#include <cxxreact/ErrorUtils.h>
#include <react/renderer/debug/SystraceSection.h>
#include <utility>
#include "ErrorUtils.h"
namespace facebook::react {
@@ -136,7 +136,7 @@ void RuntimeScheduler_Legacy::callExpiredTasks(jsi::Runtime& runtime) {
executeTask(runtime, topPriorityTask, didUserCallbackTimeout);
}
} catch (jsi::JSError& error) {
handleFatalError(runtime, error);
handleJSError(runtime, error, true);
}
currentPriority_ = previousPriority;
@@ -182,7 +182,7 @@ void RuntimeScheduler_Legacy::startWorkLoop(jsi::Runtime& runtime) {
executeTask(runtime, topPriorityTask, didUserCallbackTimeout);
}
} catch (jsi::JSError& error) {
handleFatalError(runtime, error);
handleJSError(runtime, error, true);
}
currentPriority_ = previousPriority;
@@ -12,7 +12,6 @@
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/debug/SystraceSection.h>
#include <utility>
#include "ErrorUtils.h"
namespace facebook::react {
@@ -244,7 +243,7 @@ void RuntimeScheduler_Modern::startWorkLoop(
executeTask(runtime, *topPriorityTask, currentTime);
}
} catch (jsi::JSError& error) {
handleFatalError(runtime, error);
handleJSError(runtime, error, true);
}
currentPriority_ = previousPriority;