From f355ecbbc9304b7510a4b7f0540e40ac072b5eed Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Wed, 19 Oct 2022 16:35:20 +0800 Subject: [PATCH] fix(console): show i18n content of "errors.unknown_server_error" --- packages/console/src/hooks/use-api.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/console/src/hooks/use-api.ts b/packages/console/src/hooks/use-api.ts index 8f137fd77..430da0394 100644 --- a/packages/console/src/hooks/use-api.ts +++ b/packages/console/src/hooks/use-api.ts @@ -21,11 +21,13 @@ export class RequestError extends Error { } const toastError = async (response: Response) => { + const fallbackErrorMessage = t('admin_console.errors.unknown_server_error'); + try { const data = await response.json(); - toast.error([data.message, data.details].join('\n') || t('errors.unknown_server_error')); + toast.error([data.message, data.details].join('\n') || fallbackErrorMessage); } catch { - toast.error(t('errors.unknown_server_error')); + toast.error(fallbackErrorMessage); } };