| 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 styles from './shared.css'; |
| 12 | |
| 13 | type Props = { |
| 14 | callStack: string | null, |
| 15 | children: React$Node, |
| 16 | info: React$Node | null, |
| 17 | componentStack: string | null, |
| 18 | errorMessage: string, |
| 19 | }; |
| 20 | |
| 21 | export default function CaughtErrorView({ |
| 22 | callStack, |
| 23 | children, |
| 24 | info, |
| 25 | componentStack, |
| 26 | errorMessage, |
| 27 | }: Props): React.Node { |
| 28 | return ( |
| 29 | <div className={styles.ErrorBoundary}> |
| 30 | {children} |
| 31 | <div className={styles.ErrorInfo}> |
| 32 | <div className={styles.HeaderRow}> |
| 33 | <div className={styles.ErrorHeader}>{errorMessage}</div> |
| 34 | </div> |
| 35 | {!!info && <div className={styles.InfoBox}>{info}</div>} |
| 36 | {!!callStack && ( |
| 37 | <div className={styles.ErrorStack}> |
| 38 | The error was thrown {callStack.trim()} |
| 39 | </div> |
| 40 | )} |
| 41 | </div> |
| 42 | </div> |
| 43 | ); |
| 44 | } |