diff --git a/src/components/TranslatedError.js b/src/components/TranslatedError.js index fe68cd6e..d5e8257c 100644 --- a/src/components/TranslatedError.js +++ b/src/components/TranslatedError.js @@ -24,7 +24,10 @@ class TranslatedError extends PureComponent { if (!error) return null if (typeof error !== 'object') { // this case should not happen (it is supposed to be a ?Error) - logger.critical(error) + logger.critical(`TranslatedError invalid usage: ${String(error)}`) + if (typeof error === 'string') { + return error // TMP in case still used somewhere + } return null } if (error.name) { diff --git a/src/components/base/Input/index.js b/src/components/base/Input/index.js index 44ac36cc..5cd59dca 100644 --- a/src/components/base/Input/index.js +++ b/src/components/base/Input/index.js @@ -87,7 +87,7 @@ type Props = { renderLeft?: any, renderRight?: any, containerProps?: Object, - error?: string | boolean, + error?: ?Error | boolean, small?: boolean, editInPlace?: boolean, } diff --git a/src/components/modals/AccountSettingRenderBody.js b/src/components/modals/AccountSettingRenderBody.js index 6832a354..a1126a98 100644 --- a/src/components/modals/AccountSettingRenderBody.js +++ b/src/components/modals/AccountSettingRenderBody.js @@ -214,7 +214,7 @@ class HelperComp extends PureComponent { maxLength={MAX_ACCOUNT_NAME_SIZE} onChange={this.handleChangeName} onFocus={e => this.handleFocus(e, 'accountName')} - error={accountNameError && t('app:account.settings.accountName.error')} + error={accountNameError && new Error(t('app:account.settings.accountName.error'))} /> @@ -251,7 +251,9 @@ class HelperComp extends PureComponent { onChange={this.handleChangeEndpointConfig} onFocus={e => this.handleFocus(e, 'endpointConfig')} error={ - endpointConfigError ? t('app:account.settings.endpointConfig.error') : false + endpointConfigError + ? new Error(t('app:account.settings.endpointConfig.error')) + : null } /> diff --git a/src/components/modals/Send/fields/RecipientField.js b/src/components/modals/Send/fields/RecipientField.js index d1615bea..67c69e60 100644 --- a/src/components/modals/Send/fields/RecipientField.js +++ b/src/components/modals/Send/fields/RecipientField.js @@ -9,6 +9,7 @@ import Box from 'components/base/Box' import LabelWithExternalIcon from 'components/base/LabelWithExternalIcon' import RecipientAddress from 'components/RecipientAddress' import { track } from 'analytics/segment' +import { createCustomErrorClass } from 'helpers/errors' type Props = { t: T, @@ -19,6 +20,8 @@ type Props = { autoFocus?: boolean, } +const InvalidAddress = createCustomErrorClass('InvalidAddress') + class RecipientField extends Component, { isValid: boolean }> { state = { isValid: true, @@ -79,7 +82,13 @@ class RecipientField extends Component, { isVali diff --git a/static/i18n/en/errors.yml b/static/i18n/en/errors.yml index fe0aee02..20b80264 100644 --- a/static/i18n/en/errors.yml +++ b/static/i18n/en/errors.yml @@ -100,3 +100,5 @@ WrongDeviceForAccount: DeviceAppVerifyNotSupported: title: Open Manager to update this App description: The app verification is not supported +InvalidAddress: + title: 'This is not a valid {{currencyName}} address'