From: Daniela Brozzoni Date: Wed, 14 Sep 2022 13:21:52 +0000 (+0200) Subject: Don't create wallet instance in a try/catch block X-Git-Url: http://internal-gitweb-vhost/script/%22https:/-sqlite-db-configuration/static/trait.CoinSelectionAlgorithm.html?a=commitdiff_plain;h=6bbc3d93f2aeb49b718b23f8106bd3bfcd260747;p=bitcoindevkit.org Don't create wallet instance in a try/catch block Before, failing to create the wallet instance wouldn't report the error back to the caller, which would usually go on and call methods on inst, casuing null pointer exceptions. You can try this by entering the current playground and inserting a descriptor with a mismatched checksum: the error would be logged in the console, but a weird error would be presented to the user. --- diff --git a/playground/src/index.js b/playground/src/index.js index de18abb325..d0d3642b09 100644 --- a/playground/src/index.js +++ b/playground/src/index.js @@ -15,16 +15,12 @@ async function startWallet(desc, change_desc) { let historyIndex = 0; let inst = null; - try { - let args = ["_", "-d", desc]; - if (change_desc) { - args.push("-c"); - args.push(change_desc); - } - inst = await new WasmWallet("testnet", args); - } catch (e) { - console.error(e); + let args = ["_", "-d", desc]; + if (change_desc) { + args.push("-c"); + args.push(change_desc); } + inst = await new WasmWallet("testnet", args); const run = (command) => { if (command == "clear") {