From 92136272b09ef83b7779d7f10dac822b193e9fbd Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Jan 2023 16:13:57 +0900 Subject: [PATCH] enhance(client): show readable error when rate limit exceeded --- CHANGELOG.md | 1 + locales/ja-JP.yml | 2 ++ packages/frontend/src/os.ts | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee25c7672..06c9ee11e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,7 @@ You should also include the user name that made the change. - Client: Add link to user RSS feed in profile menu @ssmucny - Client: Compress non-animated PNG files @saschanaz - Client: YouTube window player @sim1222 +- Client: show readable error when rate limit exceeded @syuilo - Client: enhance dashboard of control panel @syuilo - Client: Vite is upgraded to v4 @syuilo, @tamaina - Client: HMR is available while yarn dev @tamaina diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 67464e943..ea3cc6c9e 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -933,6 +933,8 @@ unassign: "アサインを解除" color: "色" manageCustomEmojis: "カスタム絵文字の管理" youCannotCreateAnymore: "これ以上作成することはできません。" +cannotPerformTemporary: "一時的に利用できません" +cannotPerformTemporaryDescription: "操作回数が制限を超過するため一時的に利用できません。しばらく時間を置いてから再度お試しください。" _role: new: "ロールの作成" diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index 891d598d8..3c44ed6ea 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -20,7 +20,10 @@ export const apiWithDialog = (( promiseDialog(promise, null, (err) => { let title = null; let text = err.message + '\n' + (err as any).id; - if (err.code.startsWith('TOO_MANY')) { + if (err.code === 'RATE_LIMIT_EXCEEDED') { + title = i18n.ts.cannotPerformTemporary; + text = i18n.ts.cannotPerformTemporaryDescription; + } else if (err.code.startsWith('TOO_MANY')) { title = i18n.ts.youCannotCreateAnymore; text = `${i18n.ts.error}: ${err.id}`; }