2023-05-06 21:51:17 +00:00
|
|
|
import { Component } from 'react'
|
2023-07-23 15:08:43 +00:00
|
|
|
import { StaticLayout } from './layout'
|
2023-07-29 19:38:20 +00:00
|
|
|
import styles from '../styles/error.module.css'
|
2023-07-25 14:14:45 +00:00
|
|
|
import Image from 'react-bootstrap/Image'
|
2023-02-08 21:56:43 +00:00
|
|
|
|
2023-05-06 21:51:17 +00:00
|
|
|
class ErrorBoundary extends Component {
|
2023-02-08 21:56:43 +00:00
|
|
|
constructor (props) {
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
// Define a state variable to track whether is an error or not
|
|
|
|
this.state = { hasError: false }
|
|
|
|
}
|
|
|
|
|
|
|
|
static getDerivedStateFromError () {
|
|
|
|
// Update state so the next render will show the fallback UI
|
|
|
|
return { hasError: true }
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidCatch (error, errorInfo) {
|
|
|
|
// You can use your own error logging service here
|
|
|
|
console.log({ error, errorInfo })
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
// Check if the error is thrown
|
|
|
|
if (this.state.hasError) {
|
|
|
|
// You can render any custom fallback UI
|
|
|
|
return (
|
2023-07-23 15:08:43 +00:00
|
|
|
<StaticLayout>
|
2023-07-29 19:38:20 +00:00
|
|
|
<Image width='500' height='375' className='rounded-1 shadow-sm' src={`${process.env.NEXT_PUBLIC_ASSET_PREFIX}/floating.gif`} fluid />
|
|
|
|
<h1 className={styles.status} style={{ fontSize: '48px' }}>something went wrong</h1>
|
2023-07-23 15:08:43 +00:00
|
|
|
</StaticLayout>
|
2023-02-08 21:56:43 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return children components in case of no error
|
|
|
|
|
|
|
|
return this.props.children
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ErrorBoundary
|