finish off error handling

This commit is contained in:
41666 2019-03-19 01:14:21 -05:00
parent 02056c5faf
commit 1b8d90b24b
2 changed files with 24 additions and 3 deletions

View file

@ -83,7 +83,7 @@ class RoleypolyApp extends App {
` }} />
</Head>
<Layout user={user} {...layout}>
<ErrorCaughtComponent {...pageProps} router={router} />
<ErrorCaughtComponent {...pageProps} router={router} originalName={Component.displayName || Component.constructor.name} />
</Layout>
</Container>
}

View file

@ -127,6 +127,23 @@ export default class CustomErrorPage extends React.Component {
</div>
}
renderServer () {
return <div>
<Overlay />
<ResponsiveSplitter>
<div>
<Code>Oops.</Code>
</div>
<div>
<section>
Server was unhappy about this render. Try reloading or changing page.
</section>
<JapaneseFlair>クッキーを送ってください</JapaneseFlair>
</div>
</ResponsiveSplitter>
</div>
}
handlers = {
403: this.render403,
404: this.render404,
@ -134,10 +151,14 @@ export default class CustomErrorPage extends React.Component {
}
render () {
if (this.props.originalName === 'ErrorPage') {
return this.renderServer()
}
if (this.props.statusCode in this.handlers) {
return this.handlers[this.props.statusCode]()
} else {
return this.renderDefault()
}
return this.renderDefault()
}
}