From 487c8489f1fb88b07acbcd61c223f7c3c0c32f9a Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Mon, 8 Apr 2024 19:36:04 -0700 Subject: [PATCH] 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 --- .../renderer/runtimescheduler/ErrorUtils.h | 34 ------------------- .../runtimescheduler/RuntimeScheduler.cpp | 1 - .../RuntimeScheduler_Legacy.cpp | 6 ++-- .../RuntimeScheduler_Modern.cpp | 3 +- 4 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 packages/react-native/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h diff --git a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h deleted file mode 100644 index a73bb52ce3c..00000000000 --- a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h +++ /dev/null @@ -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 - -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 diff --git a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp index 79be477d2c2..77842df7034 100644 --- a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +++ b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp @@ -13,7 +13,6 @@ #include #include #include -#include "ErrorUtils.h" namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Legacy.cpp b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Legacy.cpp index 812eac2456d..e27517b1ed2 100644 --- a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Legacy.cpp +++ b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Legacy.cpp @@ -8,9 +8,9 @@ #include "RuntimeScheduler_Legacy.h" #include "SchedulerPriorityUtils.h" +#include #include #include -#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; diff --git a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp index f1ca55c7af3..0956ada82fa 100644 --- a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp +++ b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp @@ -12,7 +12,6 @@ #include #include #include -#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;