From 6bbc3d93f2aeb49b718b23f8106bd3bfcd260747 Mon Sep 17 00:00:00 2001 From: Daniela Brozzoni Date: Wed, 14 Sep 2022 15:21:52 +0200 Subject: [PATCH] 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. --- playground/src/index.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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") { -- 2.49.0