1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. import type {Fiber} from '../ReactFiber';
    
  11. import type {CapturedValue} from '../ReactCapturedValue';
    
  12. 
    
  13. import {ClassComponent} from '../ReactWorkTags';
    
  14. 
    
  15. // Module provided by RN:
    
  16. import {ReactFiberErrorDialog as RNImpl} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
    
  17. 
    
  18. if (typeof RNImpl.showErrorDialog !== 'function') {
    
  19.   throw new Error(
    
  20.     'Expected ReactFiberErrorDialog.showErrorDialog to be a function.',
    
  21.   );
    
  22. }
    
  23. 
    
  24. export function showErrorDialog(
    
  25.   boundary: Fiber,
    
  26.   errorInfo: CapturedValue<mixed>,
    
  27. ): boolean {
    
  28.   const capturedError = {
    
  29.     componentStack: errorInfo.stack !== null ? errorInfo.stack : '',
    
  30.     error: errorInfo.value,
    
  31.     errorBoundary:
    
  32.       boundary !== null && boundary.tag === ClassComponent
    
  33.         ? boundary.stateNode
    
  34.         : null,
    
  35.   };
    
  36.   return RNImpl.showErrorDialog(capturedError);
    
  37. }