2019-07-16 02:06:16 +02:00
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
class Error extends React.Component {
|
2019-11-11 04:24:53 +01:00
|
|
|
static getInitialProps({ res, err }) {
|
2019-07-16 02:06:16 +02:00
|
|
|
const statusCode = res ? res.statusCode : err ? err.statusCode : null
|
|
|
|
return { statusCode }
|
|
|
|
}
|
|
|
|
|
2019-11-11 04:24:53 +01:00
|
|
|
render() {
|
2019-07-16 02:06:16 +02:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h3>Custom error!!</h3>
|
|
|
|
<p>
|
|
|
|
{this.props.statusCode
|
|
|
|
? `An error ${this.props.statusCode} occurred on server`
|
|
|
|
: 'An error occurred on client'}
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Error
|