From 99b073d79d88b982f9fe2d974fdbd14c6ac479c7 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 18 Aug 2025 12:40:25 -0700 Subject: [PATCH] Fix errors thrown and not caught. --- src/lib/wallet/create.ts | 12 ++++++------ src/lib/wallet/load.ts | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/wallet/create.ts b/src/lib/wallet/create.ts index 706b18c..a9c65be 100644 --- a/src/lib/wallet/create.ts +++ b/src/lib/wallet/create.ts @@ -10,13 +10,13 @@ import { NamedData } from '#types' export async function _create (wallet: Wallet, vault: Vault, password: string, mnemonicSalt?: string): Promise> export async function _create (wallet: Wallet, vault: Vault, password: unknown, mnemonicSalt?: unknown): Promise> { - if (typeof password !== 'string') { - throw new TypeError('Invalid password', { cause: typeof password }) - } - if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') { - throw new TypeError('Mnemonic salt must be a string') - } try { + if (typeof password !== 'string') { + throw new TypeError('Invalid password', { cause: typeof password }) + } + if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') { + throw new TypeError('Mnemonic salt must be a string') + } const { iv, salt, encrypted, seed, mnemonic } = await vault.request({ action: 'create', type: wallet.type, diff --git a/src/lib/wallet/load.ts b/src/lib/wallet/load.ts index bd0f77f..684783a 100644 --- a/src/lib/wallet/load.ts +++ b/src/lib/wallet/load.ts @@ -10,16 +10,16 @@ import { Vault } from '../vault' export async function _load (wallet: Wallet, vault: Vault, password: string, secret: string, mnemonicSalt?: string): Promise export async function _load (wallet: Wallet, vault: Vault, password: unknown, secret: unknown, mnemonicSalt?: unknown): Promise { - if (typeof password !== 'string') { - throw new TypeError('Password must be a string') - } - if (typeof secret !== 'string') { - throw new TypeError('Wallet secret must be a string') - } - if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') { - throw new TypeError('Mnemonic salt must be a string') - } try { + if (typeof password !== 'string') { + throw new TypeError('Password must be a string') + } + if (typeof secret !== 'string') { + throw new TypeError('Wallet secret must be a string') + } + if (mnemonicSalt !== undefined && typeof mnemonicSalt !== 'string') { + throw new TypeError('Mnemonic salt must be a string') + } const data: NamedData = { action: 'load', type: wallet.type, -- 2.47.3