From 3bf3d96d9f0e9e59d19939d0b5ff9159249b3c1c Mon Sep 17 00:00:00 2001 From: David Luzar Date: Mon, 9 Mar 2020 17:09:45 +0100 Subject: [PATCH] make error message more user-friendly (#812) * make error message more user-friendly * tweak aria * override user-select for error splash screen * localize messages * fix naming * log error * include spaces in i18n --- src/bug-issue-template.js | 4 +-- src/components/TopErrorBoundary.tsx | 43 +++++++++++++++++------------ src/locales/en.json | 13 +++++++++ src/styles.scss | 6 +++- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/bug-issue-template.js b/src/bug-issue-template.js index 9c45ec9d8..9dfe1eaf6 100644 --- a/src/bug-issue-template.js +++ b/src/bug-issue-template.js @@ -5,9 +5,9 @@ export default ` // paste stack trace here \`\`\` -### localStorage +### Scene content \`\`\` -// paste localStorage content here (if it doesn't contain sensitive data) +// paste scene content here (if it doesn't contain sensitive data) \`\`\` `; diff --git a/src/components/TopErrorBoundary.tsx b/src/components/TopErrorBoundary.tsx index 08e56a8fb..fcbc40e6f 100644 --- a/src/components/TopErrorBoundary.tsx +++ b/src/components/TopErrorBoundary.tsx @@ -1,4 +1,6 @@ import React from "react"; +import { resetCursor } from "../utils"; +import { t } from "../i18n"; interface TopErrorBoundaryState { unresolvedError: Error[] | null; @@ -19,11 +21,12 @@ export class TopErrorBoundary extends React.Component< }; componentDidCatch(error: Error) { + resetCursor(); const _localStorage: any = {}; for (const [key, value] of Object.entries({ ...localStorage })) { try { _localStorage[key] = JSON.parse(value); - } catch { + } catch (error) { _localStorage[key] = value; } } @@ -90,49 +93,55 @@ export class TopErrorBoundary extends React.Component< return (
-
- Encountered an error. Please{" "} +
+ {t("errorSplash.headingMain_pre")} - .
-
- If reloading doesn't work. Try{" "} +
+ {t("errorSplash.clearCanvasMessage")} - .
+
- (This will unfortunately result in loss of work.) + + ⚠️ + + {t("errorSplash.clearCanvasCaveat")} +
- Before doing so, we'd appreciate if you opened an issue on our{" "} - . - Please include the following error stack trace & localStorage - content (provided it's not private): + {t("errorSplash.openIssueMessage_pre")} + + {t("errorSplash.openIssueMessage_post")}
- +