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-04-08 19:36:04 -07:00
committed by Facebook GitHub Bot
parent 9ad71387e8
commit 3094273e8b
4 changed files with 4 additions and 42 deletions
@@ -1,36 +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.
*/
#pragma once
#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,10 +8,10 @@
#include "RuntimeScheduler_Legacy.h"
#include "SchedulerPriorityUtils.h"
#include <cxxreact/ErrorUtils.h>
#include <react/renderer/consistency/ScopedShadowTreeRevisionLock.h>
#include <react/renderer/debug/SystraceSection.h>
#include <utility>
#include "ErrorUtils.h"
namespace facebook::react {
@@ -139,7 +139,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;
@@ -191,7 +191,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;
@@ -14,7 +14,6 @@
#include <react/renderer/debug/SystraceSection.h>
#include <react/utils/OnScopeExit.h>
#include <utility>
#include "ErrorUtils.h"
namespace facebook::react {
@@ -211,7 +210,7 @@ void RuntimeScheduler_Modern::startWorkLoop(
executeTask(runtime, topPriorityTask, currentTime);
}
} catch (jsi::JSError& error) {
handleFatalError(runtime, error);
handleJSError(runtime, error, true);
}
currentPriority_ = previousPriority;