File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
packages/react-debug-tools/src Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,10 @@ export const ErrorsNames = {
1818 UNSUPPORTTED_FEATURE_ERROR : 'UnsupportedFeatureError' ,
1919} ;
2020
21- export function UnsupportedFeatureError ( message : string = "" ) {
22- // Make this an instanceof Error.
23- this . constructor . prototype . __proto__ = Error . prototype ;
24-
25- this . name = ErrorsNames . UNSUPPORTTED_FEATURE_ERROR ;
26- this . message = message ;
27- if ( Error . captureStackTrace ) { // only available in V8
28- Error . captureStackTrace ( this , this . constructor ) ;
29- }
21+ // For now we just override the name. If we decide to move react-debug-tools to
22+ // devtools package, we should use a real Error class instead.
23+ export function createUnsupportedFeatureError ( message : string = "" ) {
24+ const error = new Error ( message ) ;
25+ error . name = ErrorsNames . UNSUPPORTTED_FEATURE_ERROR ;
26+ return error ;
3027}
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import {
2929 ContextProvider ,
3030 ForwardRef ,
3131} from 'react-reconciler/src/ReactWorkTags' ;
32- import { UnsupportedFeatureError } from './ReactDebugCustomErrors' ;
32+ import { createUnsupportedFeatureError } from './ReactDebugCustomErrors' ;
3333
3434type CurrentDispatcherRef = typeof ReactSharedInternals . ReactCurrentDispatcher ;
3535
@@ -364,7 +364,7 @@ const DispatcherProxyHandler = {
364364 if ( target . hasOwnProperty ( prop ) ) {
365365 return Reflect . get ( ...arguments ) ;
366366 }
367- throw new UnsupportedFeatureError ('Missing method in Dispatcher: ' + prop);
367+ throw createUnsupportedFeatureError ('Missing method in Dispatcher: ' + prop);
368368 } ,
369369} ;
370370
You can’t perform that action at this time.
0 commit comments