-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Settings window error handling, fixed minor errors
- Loading branch information
1 parent
d7fa155
commit 9e052a7
Showing
4 changed files
with
418 additions
and
379 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,29 @@ | ||
import React from "react"; | ||
|
||
export default class SafeRender extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { hasError: false, error: "" }; | ||
} | ||
|
||
static getDerivedStateFromError(error) { | ||
return { hasError: true, error: error }; | ||
} | ||
|
||
componentDidCatch(error, errorInfo) { | ||
console.log(error) | ||
this.setState({ | ||
hasError: true, | ||
error: error, | ||
errorInfo: errorInfo?.componentStack | ||
}) | ||
} | ||
|
||
render() { | ||
if (this.state.hasError) { | ||
return (<pre className="try-catch-failure">Error: {JSON.stringify(this.state.error)}<br />{this.state.errorInfo}</pre>); | ||
} | ||
|
||
return <>{this.props?.children}</>; | ||
} | ||
} |
Oops, something went wrong.