Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve error messages #232

Merged
merged 7 commits into from
Jul 12, 2024
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ node_modules/
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# exclude webstorm profile file
.idea/
gantunesr marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 3 additions & 1 deletion src/ledger-keyring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ describe('LedgerKeyring', function () {
it('throws an error when the bridge getPublicKey method throws an error and it is not an error type', async function () {
keyring.setHdPath(`m/44'/60'/0'/0`);
jest.spyOn(bridge, 'getPublicKey').mockRejectedValue('Some error');
await expect(keyring.unlock()).rejects.toThrow('Unknown error');
await expect(keyring.unlock()).rejects.toThrow(
'Unlock your Ledger device and open the ETH app',
);
});
});

Expand Down
4 changes: 3 additions & 1 deletion src/ledger-keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ export class LedgerKeyring extends EventEmitter {
hdPath: path,
});
} catch (error) {
throw error instanceof Error ? error : new Error('Unknown error');
throw error instanceof Error
? error
: new Error('Unlock your Ledger device and open the ETH app');
gantunesr marked this conversation as resolved.
Show resolved Hide resolved
}

if (updateHdk && payload.chainCode) {
Expand Down
Loading