Skip to content

Commit

Permalink
Improved Settings window error handling, fixed minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Nov 8, 2023
1 parent d7fa155 commit 9e052a7
Show file tree
Hide file tree
Showing 4 changed files with 418 additions and 379 deletions.
29 changes: 29 additions & 0 deletions src/components/SafeRender.jsx
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}</>;
}
}
Loading

0 comments on commit 9e052a7

Please sign in to comment.