diff --git a/src/helpers/apps/installApp.js b/src/helpers/apps/installApp.js index 96f1af75..00dfb4fd 100644 --- a/src/helpers/apps/installApp.js +++ b/src/helpers/apps/installApp.js @@ -9,14 +9,26 @@ import type { LedgerScriptParams } from 'helpers/common' import createCustomErrorClass from '../createCustomErrorClass' -const CannotInstall = createCustomErrorClass('CannotInstall') +const ManagerUnexpectedError = createCustomErrorClass('ManagerUnexpected') +const ManagerNotEnoughSpaceError = createCustomErrorClass('ManagerNotEnoughSpace') +const ManagerDeviceLockedError = createCustomErrorClass('ManagerDeviceLocked') +const ManagerAppAlreadyInstalledError = createCustomErrorClass('ManagerAppAlreadyInstalled') +const ManagerAppRelyOnBTCError = createCustomErrorClass('ManagerAppRelyOnBTC') function remapError(promise) { return promise.catch((e: Error) => { - if (e.message.endsWith('6982')) { - throw new CannotInstall() + switch (true) { + case e.message.endsWith('6982'): + throw new ManagerDeviceLockedError() + case e.message.endsWith('6a84') || e.message.endsWith('6a85'): + throw new ManagerNotEnoughSpaceError() + case e.message.endsWith('6a80') || e.message.endsWith('6a81'): + throw new ManagerAppAlreadyInstalledError() + case e.message.endsWith('6a83'): + throw new ManagerAppRelyOnBTCError() + default: + throw new ManagerUnexpectedError(e.message, { msg: e.message }) } - throw e }) } diff --git a/src/helpers/apps/uninstallApp.js b/src/helpers/apps/uninstallApp.js index 6ead5304..1611a1b4 100644 --- a/src/helpers/apps/uninstallApp.js +++ b/src/helpers/apps/uninstallApp.js @@ -8,14 +8,20 @@ import { createDeviceSocket } from 'helpers/socket' import type { LedgerScriptParams } from 'helpers/common' import createCustomErrorClass from '../createCustomErrorClass' -const CannotUninstall = createCustomErrorClass('CannotUninstall') +const ManagerUnexpectedError = createCustomErrorClass('ManagerUnexpectedError') +const ManagerDeviceLockedError = createCustomErrorClass('ManagerDeviceLocked') +const ManagerUninstallBTCDep = createCustomErrorClass('ManagerUninstallBTCDep') function remapError(promise) { return promise.catch((e: Error) => { - if (e.message.endsWith('6a83')) { - throw new CannotUninstall() + switch (true) { + case e.message.endsWith('6982'): + throw new ManagerDeviceLockedError() + case e.message.endsWith('6a83'): + throw new ManagerUninstallBTCDep() + default: + throw new ManagerUnexpectedError(e.message, { msg: e.message }) } - throw e }) } diff --git a/static/i18n/en/errors.yml b/static/i18n/en/errors.yml index 95ce4465..640ff96d 100644 --- a/static/i18n/en/errors.yml +++ b/static/i18n/en/errors.yml @@ -21,5 +21,11 @@ DeviceSocketNoBulkStatus: Oops, device connection failed. Please try again [bulk DeviceSocketNoHandler: Oops, device connection failed (handler {{query}}). Please try again. LatestMCUInstalledError: MCU on device already up to date. HardResetFail: Reset failed. Please try again. -CannotUninstall: Cannot uninstall app. -CannotInstall: Not enough room left on your device. Please uninstall some apps and try again. + +ManagerAPIsFail: Our services are currently unavailable. Please try again later. +ManagerUnexpected: Unexpected error occurred ({{msg}}). Please try again later. +ManagerNotEnoughSpace: Not enough room left on your device. Please uninstall some apps and try again. +ManagerDeviceLocked: Device is locked +ManagerAppAlreadyInstalled: App is already installed +ManagerAppRelyOnBTC: You must install Bitcoin application first +ManagerUninstallBTCDep: You must uninstall other altcoins first