You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
900 B
JavaScript

import React from 'react'
import getConfig from 'next/config'
const {publicRuntimeConfig} = getConfig()
const ErrorPage = ({error}) => {
const env = publicRuntimeConfig.SOS_ENV
if (!error)
return (
<>
<h2>Not Found</h2>
<p>This page was not found</p>
</>
)
5 years ago
return (
<>
<h2>{error.name}</h2>
<p>{error.message}</p>
{env === 'development' && (
<>
{error.stack && (
<p>
<pre>
{error.stack}
</pre>
</p>
)}
<p>
<pre>
{JSON.stringify(error, null, 2)}
</pre>
</p>
</>
)}
</>
)
}
ErrorPage.getInitialProps = ({ctx: {err, req, res}}) => {
if(!err) return {error: null}
if(res)
err.status = res.statusCode
5 years ago
return { error: err }
}
5 years ago
export default ErrorPage