From a6d6120be3441f120fcc79dd77179fb2aaedf368 Mon Sep 17 00:00:00 2001 From: Ashelyn Dawn Date: Fri, 3 Apr 2020 20:55:35 -0600 Subject: [PATCH] Tweaking error display --- components/errorDisplay/errorDisplay.js | 1 + components/header/header.js | 2 +- pages/_error.js | 10 ++++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/errorDisplay/errorDisplay.js b/components/errorDisplay/errorDisplay.js index 7503724..9c80f66 100644 --- a/components/errorDisplay/errorDisplay.js +++ b/components/errorDisplay/errorDisplay.js @@ -2,6 +2,7 @@ export default function ErrorDisplay({error}){ return ( <>

{error.name}

+

{error.message}

) } diff --git a/components/header/header.js b/components/header/header.js index 3c8ac3e..1320836 100644 --- a/components/header/header.js +++ b/components/header/header.js @@ -33,7 +33,7 @@ const Header = () => { ):( <>
  • Account
  • - {user.admin &&
  • Admin
  • } + {user.is_admin &&
  • Admin
  • }
  • Log out
  • ) diff --git a/pages/_error.js b/pages/_error.js index 4fe03ae..b1e11c0 100644 --- a/pages/_error.js +++ b/pages/_error.js @@ -1,19 +1,17 @@ import React from 'react' import ErrorDisplay from '~/components/errorDisplay' -const ErrorPage = ({statusCode}) => ( - <> - - +const ErrorPage = ({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 } }