Fix dynamic translation key error handling
- Add proper fallback for undefined statusText in error alerts - Prevent accessing 'errors.undefined' translation key - Handle cases where axiosError.statusText is undefined 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
903ab8aeb1
commit
74cdbe5c70
3 changed files with 9 additions and 3 deletions
|
|
@ -508,7 +508,9 @@ const CharacterGrid = (props: Props) => {
|
||||||
<Alert
|
<Alert
|
||||||
open={errorAlertOpen}
|
open={errorAlertOpen}
|
||||||
title={axiosError ? `${axiosError.status}` : 'Error'}
|
title={axiosError ? `${axiosError.status}` : 'Error'}
|
||||||
message={t(`errors.${axiosError?.statusText.toLowerCase()}`)}
|
message={axiosError?.statusText && axiosError.statusText !== 'undefined'
|
||||||
|
? t(`errors.${axiosError.statusText.toLowerCase()}`)
|
||||||
|
: t('errors.internal_server_error.description')}
|
||||||
cancelAction={() => setErrorAlertOpen(false)}
|
cancelAction={() => setErrorAlertOpen(false)}
|
||||||
cancelActionText={t('buttons.confirm')}
|
cancelActionText={t('buttons.confirm')}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,9 @@ const SummonGrid = (props: Props) => {
|
||||||
<Alert
|
<Alert
|
||||||
open={errorAlertOpen}
|
open={errorAlertOpen}
|
||||||
title={axiosError ? `${axiosError.status}` : 'Error'}
|
title={axiosError ? `${axiosError.status}` : 'Error'}
|
||||||
message={t(`errors.${axiosError?.statusText.toLowerCase()}`)}
|
message={axiosError?.statusText && axiosError.statusText !== 'undefined'
|
||||||
|
? t(`errors.${axiosError.statusText.toLowerCase()}`)
|
||||||
|
: t('errors.internal_server_error.description')}
|
||||||
cancelAction={() => setErrorAlertOpen(false)}
|
cancelAction={() => setErrorAlertOpen(false)}
|
||||||
cancelActionText={t('buttons.confirm')}
|
cancelActionText={t('buttons.confirm')}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,9 @@ const WeaponGrid = (props: Props) => {
|
||||||
<Alert
|
<Alert
|
||||||
open={errorAlertOpen}
|
open={errorAlertOpen}
|
||||||
title={axiosError ? `${axiosError.status}` : 'Error'}
|
title={axiosError ? `${axiosError.status}` : 'Error'}
|
||||||
message={t(`errors.${axiosError?.statusText.toLowerCase()}`)}
|
message={axiosError?.statusText && axiosError.statusText !== 'undefined'
|
||||||
|
? t(`errors.${axiosError.statusText.toLowerCase()}`)
|
||||||
|
: t('errors.internal_server_error.description')}
|
||||||
cancelAction={() => setErrorAlertOpen(false)}
|
cancelAction={() => setErrorAlertOpen(false)}
|
||||||
cancelActionText={t('buttons.confirm')}
|
cancelActionText={t('buttons.confirm')}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue