diff --git a/packages/react-debug-tools/src/ReactDebugCustomErrors.js b/packages/react-debug-tools/src/ReactDebugCustomErrors.js deleted file mode 100644 index ae3a22446a..0000000000 --- a/packages/react-debug-tools/src/ReactDebugCustomErrors.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -/** - * This file contains a list of custom Errors that ReactDebugTools can throw in - * special occasions. - * The names of the errors are exported so that other packages (such as DevTools) - * can use them to detect and handle them separately. - */ - -export const ErrorsNames = { - UNSUPPORTTED_FEATURE_ERROR: 'UnsupportedFeatureError', -}; - -// For now we just override the name. If we decide to move react-debug-tools to -// devtools package, we should use a real Error class instead. -export function createUnsupportedFeatureError(message: string = '') { - const error = new Error(message); - error.name = ErrorsNames.UNSUPPORTTED_FEATURE_ERROR; - return error; -} diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 9f1a9e2472..c013d3488d 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -29,7 +29,6 @@ import { ContextProvider, ForwardRef, } from 'react-reconciler/src/ReactWorkTags'; -import {createUnsupportedFeatureError} from './ReactDebugCustomErrors'; type CurrentDispatcherRef = typeof ReactSharedInternals.ReactCurrentDispatcher; @@ -362,11 +361,13 @@ const Dispatcher: DispatcherType = { const DispatcherProxyHandler = { get(target, prop, _receiver) { if (target.hasOwnProperty(prop)) { - return Reflect.get(...arguments); + return target[prop]; } - throw createUnsupportedFeatureError( - 'Missing method in Dispatcher: ' + prop, - ); + const error = new Error('Missing method in Dispatcher: ' + prop); + // Note: This error name needs to stay in sync with react-devtools-shared + // TODO: refactor this if we ever combine the devtools and debug tools packages + error.name = 'UnsupportedFeatureError'; + throw error; }, }; diff --git a/packages/react-debug-tools/src/ReactDebugTools.js b/packages/react-debug-tools/src/ReactDebugTools.js index ca19ce8a08..7f441e0d2f 100644 --- a/packages/react-debug-tools/src/ReactDebugTools.js +++ b/packages/react-debug-tools/src/ReactDebugTools.js @@ -8,6 +8,5 @@ */ import {inspectHooks, inspectHooksOfFiber} from './ReactDebugHooks'; -import {ErrorsNames} from './ReactDebugCustomErrors'; -export {inspectHooks, inspectHooksOfFiber, ErrorsNames}; +export {inspectHooks, inspectHooksOfFiber};