diff --git a/src/helpers/error-handler.ts b/src/helpers/error-handler.ts index 3d04dbd..2689140 100644 --- a/src/helpers/error-handler.ts +++ b/src/helpers/error-handler.ts @@ -1,6 +1,7 @@ import { errors } from '@/errors' import { bus, BUS_EVENTS } from '@/helpers' import { i18n } from '@/localization' +import { capitalize } from './text.helpers' import log from 'loglevel' export class ErrorHandler { @@ -76,7 +77,13 @@ export class ErrorHandler { errorMessage = t('errors.provider-json-rpc-version-not-supported') break default: { - errorMessage = t('errors.default') + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const reason = (error as any)?.reason + + errorMessage = + typeof reason === 'string' && reason.length + ? capitalize(reason) + : t('errors.default') } } } diff --git a/src/helpers/text.helpers.ts b/src/helpers/text.helpers.ts index 3b7ee1f..0d4c4ec 100644 --- a/src/helpers/text.helpers.ts +++ b/src/helpers/text.helpers.ts @@ -7,3 +7,8 @@ export function abbrCenter(text: string, amount = 4): string { text.length, )}` } + +export function capitalize(text: string): string { + if (!text.length) return '' + return text[0].toUpperCase().concat(text.slice(1)) +}