From 7b276a3bc01d55bcb67aae19716c64ffa27c8f31 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Wed, 23 Oct 2024 13:30:28 -0700 Subject: [PATCH] catch electrum call errors --- cw_bitcoin/lib/electrum.dart | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cw_bitcoin/lib/electrum.dart b/cw_bitcoin/lib/electrum.dart index a18c038fa..8e0669ea5 100644 --- a/cw_bitcoin/lib/electrum.dart +++ b/cw_bitcoin/lib/electrum.dart @@ -447,9 +447,14 @@ class ElectrumClient { final id = _id; idCallback?.call(id); _registryTask(id, completer); - socket!.write(jsonrpc(method: method, id: id, params: params)); + try { + socket!.write(jsonrpc(method: method, id: id, params: params)); - return completer.future; + return completer.future; + } catch (e) { + print("call error: $e"); + return null; + } } Future callWithTimeout( @@ -471,8 +476,8 @@ class ElectrumClient { return completer.future; } catch (e) { - print("callWithTimeout $e"); - rethrow; + print("callWithTimeout: $e"); + return null; } }