From f109de9ebbede4ed8544b28eee08e8a759f5a45b Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 26 Jun 2022 12:47:43 +0900 Subject: [PATCH] enhance(client): Enhance boot error display (#8879) * Change boot error message * fix * :v: * fix --- packages/backend/src/server/web/boot.js | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index 94329e11c..9fc536555 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -14,10 +14,10 @@ // ブロックの中に入れないと、定義した変数がブラウザのグローバルスコープに登録されてしまい邪魔なので (async () => { window.onerror = (e) => { - renderError('SOMETHING_HAPPENED', e.toString()); + renderError('SOMETHING_HAPPENED', e); }; window.onunhandledrejection = (e) => { - renderError('SOMETHING_HAPPENED_IN_PROMISE', e.toString()); + renderError('SOMETHING_HAPPENED_IN_PROMISE', e); }; const v = localStorage.getItem('v') || VERSION; @@ -57,7 +57,7 @@ import(`/assets/${CLIENT_ENTRY}`) .catch(async e => { await checkUpdate(); - renderError('APP_FETCH_FAILED', JSON.stringify(e)); + renderError('APP_FETCH_FAILED', e); }) //#endregion @@ -104,20 +104,27 @@ // eslint-disable-next-line no-inner-declarations function renderError(code, details) { - document.documentElement.innerHTML = ` -

⚠エラーが発生しました

-

問題が解決しない場合は管理者までお問い合わせください。以下のオプションを試すこともできます:

+ let errorsElement = document.getElementById('errors'); + if (!errorsElement) { + document.documentElement.innerHTML = ` +

⚠ An error has occurred. ⚠

+

If the problem persists, please contact the administrator. You may also try the following options:


- ERROR CODE: ${code} -
- ${details} -
- `; +
+ `; + + errorsElement = document.getElementById('errors'); + } + + const detailsElement = document.createElement('details'); + detailsElement.innerHTML = `ERROR CODE: ${code}${JSON.stringify(details)}`; + + errorsElement.appendChild(detailsElement); } // eslint-disable-next-line no-inner-declarations