From 2dd8a5b190ca772bff6592f57f789b9028b3b98a Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 27 Jan 2023 12:22:30 -0600 Subject: [PATCH] no such transaction exception --- lib/electrumx_rpc/electrumx.dart | 11 ++++++++++- lib/exceptions/electrumx/no_such_transaction.dart | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/exceptions/electrumx/no_such_transaction.dart diff --git a/lib/electrumx_rpc/electrumx.dart b/lib/electrumx_rpc/electrumx.dart index a06cc7365..a2326345d 100644 --- a/lib/electrumx_rpc/electrumx.dart +++ b/lib/electrumx_rpc/electrumx.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:decimal/decimal.dart'; import 'package:stackwallet/electrumx_rpc/rpc.dart'; +import 'package:stackwallet/exceptions/electrumx/no_such_transaction.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'package:uuid/uuid.dart'; @@ -132,7 +133,15 @@ class ElectrumX { final response = await _rpcClient!.request(jsonRequestString); if (response["error"] != null) { - throw Exception("JSONRPC response error: $response"); + if (response["error"] + .toString() + .contains("No such mempool or blockchain transaction")) { + throw NoSuchTransactionException( + "No such mempool or blockchain transaction: ${args.first}"); + } + + throw Exception( + "JSONRPC response \ncommand: $command \nargs: $args \nerror: $response"); } currentFailoverIndex = -1; diff --git a/lib/exceptions/electrumx/no_such_transaction.dart b/lib/exceptions/electrumx/no_such_transaction.dart new file mode 100644 index 000000000..a2bea262b --- /dev/null +++ b/lib/exceptions/electrumx/no_such_transaction.dart @@ -0,0 +1,5 @@ +import 'package:stackwallet/exceptions/sw_exception.dart'; + +class NoSuchTransactionException extends SWException { + NoSuchTransactionException(super.message); +}