From d3f4cd44ffb503e71cd2386a0dd2eec3c1bd5f0e Mon Sep 17 00:00:00 2001 From: Ashelyn Dawn Date: Thu, 23 Apr 2020 22:26:52 -0600 Subject: [PATCH] Error page fix --- components/errorDisplay.js | 16 ++++++++++++++-- next.config.js | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/errorDisplay.js b/components/errorDisplay.js index 9c80f66..7053e0c 100644 --- a/components/errorDisplay.js +++ b/components/errorDisplay.js @@ -1,8 +1,20 @@ +const errorMessages = { + 404: {title: 'Page not found', message: 'Unfortunately that page could not be found. If you followed a link to get here, please let the owner of the link know that they need to update it.'}, + [undefined]: {title: 'Unknown error', message: "We're not exactly sure what happened"} +} + export default function ErrorDisplay({error}){ + const defaults = errorMessages[error.status] + return ( <> -

{error.name}

-

{error.message}

+

{error.name || defaults.title}

+

{error.message || defaults.message}

+ {process.env.NODE_ENV === 'development' && ( +
+          {JSON.stringify(error, null, 2)}
+        
+ )} ) } diff --git a/next.config.js b/next.config.js index cd3e512..cbe53ac 100644 --- a/next.config.js +++ b/next.config.js @@ -69,6 +69,7 @@ module.exports = withImages({ return config }, env: { - STRIPE_PUBLIC_KEY: process.env.STRIPE_PUBLIC_KEY + STRIPE_PUBLIC_KEY: process.env.STRIPE_PUBLIC_KEY, + NODE_ENV: process.env.NODE_ENV || 'development' } })