Tweaking error display

main
Ashelyn Dawn 5 years ago
parent a567ec62ec
commit a6d6120be3

@ -2,6 +2,7 @@ export default function ErrorDisplay({error}){
return (
<>
<h1>{error.name}</h1>
<p>{error.message}</p>
</>
)
}

@ -33,7 +33,7 @@ const Header = () => {
):(
<>
<li><Link href="/account"><a>Account</a></Link></li>
{user.admin && <li><Link href="/admin"><a>Admin</a></Link></li>}
{user.is_admin && <li><Link href="/admin"><a>Admin</a></Link></li>}
<li><Link href="/api/auth/logout"><a>Log out</a></Link></li>
</>
)

@ -1,19 +1,17 @@
import React from 'react'
import ErrorDisplay from '~/components/errorDisplay'
const ErrorPage = ({statusCode}) => (
<>
<ErrorDisplay error={error} />
</>
const ErrorPage = ({error}) => (
<ErrorDisplay error={error} />
)
ErrorPage.getInitialProps = ({ res, err }) => {
let error = err;
let error = err || {};
if(!error)
error = new Error('Server Error')
error.status = err.status || (res ? res.statusCode : (error.statusCode || 404))
error.status = (err && err.status) || (res ? res.statusCode : (error.statusCode || 404))
return { error }
}

Loading…
Cancel
Save