Tweaking error display

main
Ashelyn Dawn 5 years ago
parent a567ec62ec
commit a6d6120be3

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

@ -33,7 +33,7 @@ const Header = () => {
):( ):(
<> <>
<li><Link href="/account"><a>Account</a></Link></li> <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> <li><Link href="/api/auth/logout"><a>Log out</a></Link></li>
</> </>
) )

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

Loading…
Cancel
Save