Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b6b542
commit 809ecb4
Showing
6 changed files
with
91 additions
and
8 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react' | ||
import { connect } from 'react-redux'; | ||
import { Intent, Button, Classes } from "@blueprintjs/core"; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
const log = window.require('electron-log'); | ||
|
||
export default class ErrorBoundary extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { hasError: false }; | ||
} | ||
|
||
static getDerivedStateFromError(error) { | ||
// Update state so the next render will show the fallback UI. | ||
return { hasError: true }; | ||
} | ||
|
||
componentDidCatch(error, info) { | ||
log.info(error.toString()); | ||
} | ||
|
||
resetState = () => { | ||
|
||
//@TODO: Clear states via redux action | ||
window.localStorage.clear(); | ||
window.location.reload(); | ||
} | ||
|
||
render() { | ||
if (this.state.hasError) { | ||
// You can render any custom fallback UI | ||
return (<div> | ||
<div style={{"text-align":"center"}} className="p-2"> | ||
<FontAwesomeIcon icon="frown" size="6x" className={Classes.INTENT_WARNING}/> | ||
</div> | ||
|
||
<div style={{"text-align":"center"}} className="p-2"> | ||
This is embarrasing! We appear to have run into an error. | ||
Please share the log file and a description of what you were doing when it occured with the boda-lite team to help. | ||
</div> | ||
|
||
<div style={{"text-align":"center"}} className="p-2"> | ||
<Button | ||
large={true} | ||
text="Reset App" | ||
rightIcon="refresh" intent={Intent.WARNING} | ||
onClick={this.resetState.bind(this)}> | ||
</Button> | ||
</div> | ||
</div>); | ||
} | ||
|
||
return this.props.children; | ||
} | ||
} |