diff --git a/packages/keyring-controller/src/KeyringController.ts b/packages/keyring-controller/src/KeyringController.ts index 1324b41ef26..658ae4c8b55 100644 --- a/packages/keyring-controller/src/KeyringController.ts +++ b/packages/keyring-controller/src/KeyringController.ts @@ -1005,17 +1005,21 @@ export class KeyringController extends BaseController< privateKey = remove0x(prefixed); break; case 'json': { - const getWallet = async (): Promise => { - const [input, password] = args; - try { - return importers.fromEtherWallet(input, password); - } catch (e) { - return Wallet.fromV3(input, password, true); - } - }; - const wallet = await getWallet(); - privateKey = bytesToHex(wallet.getPrivateKey()); - break; + try { + const getWallet = async (): Promise => { + const [input, password] = args; + try { + return importers.fromEtherWallet(input, password); + } catch (e) { + return Wallet.fromV3(input, password, true); + } + }; + const wallet = await getWallet(); + privateKey = bytesToHex(wallet.getPrivateKey()); + break; + } catch(e) { + throw new Error('Key derivation failed - possibly wrong passphrase'); + } } default: throw new Error(`Unexpected import strategy: '${strategy}'`);