forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show different error boundary UI for timeouts than normal errors (fac…
- Loading branch information
Showing
7 changed files
with
146 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
export default class TimeoutError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
|
||
// Maintains proper stack trace for where our error was thrown (only available on V8) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, TimeoutError); | ||
} | ||
|
||
this.name = 'TimeoutError'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/TimeoutView.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
import * as React from 'react'; | ||
import Button from '../Button'; | ||
import ButtonIcon from '../ButtonIcon'; | ||
import styles from './shared.css'; | ||
|
||
type Props = {| | ||
callStack: string | null, | ||
children: React$Node, | ||
componentStack: string | null, | ||
dismissError: Function, | ||
errorMessage: string | null, | ||
|}; | ||
|
||
export default function TimeoutView({ | ||
callStack, | ||
children, | ||
componentStack, | ||
dismissError = null, | ||
errorMessage, | ||
}: Props) { | ||
return ( | ||
<div className={styles.ErrorBoundary}> | ||
{children} | ||
<div className={styles.ErrorInfo}> | ||
<div className={styles.HeaderRow}> | ||
<div className={styles.TimeoutHeader}> | ||
{errorMessage || 'Timed out waiting'} | ||
</div> | ||
<Button className={styles.CloseButton} onClick={dismissError}> | ||
Retry | ||
<ButtonIcon className={styles.CloseButtonIcon} type="close" /> | ||
</Button> | ||
</div> | ||
{!!componentStack && ( | ||
<div className={styles.TimeoutStack}> | ||
The timeout occurred {componentStack.trim()} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters