From 6159cfd138471198206a64657dbe6a004ac822e3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 9 Feb 2023 18:07:51 +0900 Subject: [PATCH] enhance(client): improve api error handling --- locales/ja-JP.yml | 2 ++ packages/frontend/src/os.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 8e8fddfb8..09069e780 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -940,6 +940,8 @@ cannotPerformTemporaryDescription: "操作回数が制限を超過するため preset: "プリセット" selectFromPresets: "プリセットから選択" achievements: "実績" +gotInvalidResponseError: "サーバーの応答が無効です" +gotInvalidResponseErrorDescription: "サーバーがダウンまたはメンテナンスしている可能性があります。しばらくしてから再度お試しください。" _achievements: earnedAt: "獲得日時" diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index 01f824406..52469b6d0 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -35,6 +35,9 @@ export const apiWithDialog = (( } else if (err.code.startsWith('TOO_MANY')) { title = i18n.ts.youCannotCreateAnymore; text = `${i18n.ts.error}: ${err.id}`; + } else if (err.message.startsWith('Unexpected token')) { + title = i18n.ts.gotInvalidResponseError; + text = i18n.ts.gotInvalidResponseErrorDescription; } alert({ type: 'error',