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 * as React from 'react';
    
  11. import Button from '../Button';
    
  12. import ButtonIcon from '../ButtonIcon';
    
  13. import styles from './shared.css';
    
  14. 
    
  15. type Props = {
    
  16.   callStack: string | null,
    
  17.   children: React$Node,
    
  18.   componentStack: string | null,
    
  19.   dismissError: Function | null,
    
  20.   errorMessage: string | null,
    
  21. };
    
  22. 
    
  23. export default function ErrorView({
    
  24.   callStack,
    
  25.   children,
    
  26.   componentStack,
    
  27.   dismissError = null,
    
  28.   errorMessage,
    
  29. }: Props): React.Node {
    
  30.   return (
    
  31.     <div className={styles.ErrorBoundary}>
    
  32.       {children}
    
  33.       <div className={styles.ErrorInfo}>
    
  34.         <div className={styles.HeaderRow}>
    
  35.           <div className={styles.ErrorHeader}>
    
  36.             Uncaught Error: {errorMessage || ''}
    
  37.           </div>
    
  38.           {dismissError !== null && (
    
  39.             <Button className={styles.CloseButton} onClick={dismissError}>
    
  40.               Dismiss
    
  41.               <ButtonIcon className={styles.CloseButtonIcon} type="close" />
    
  42.             </Button>
    
  43.           )}
    
  44.         </div>
    
  45.         {!!callStack && (
    
  46.           <div className={styles.ErrorStack}>
    
  47.             The error was thrown {callStack.trim()}
    
  48.           </div>
    
  49.         )}
    
  50.         {!!componentStack && (
    
  51.           <div className={styles.ErrorStack}>
    
  52.             The error occurred {componentStack.trim()}
    
  53.           </div>
    
  54.         )}
    
  55.       </div>
    
  56.     </div>
    
  57.   );
    
  58. }