From: Chris Duncan Date: Mon, 18 Aug 2025 19:40:25 +0000 (-0700) Subject: Fix errors thrown and not caught. X-Git-Tag: v0.10.5~41^2~59 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=99b073d79d88b982f9fe2d974fdbd14c6ac479c7;p=libnemo.git Fix errors thrown and not caught. --- 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,