From 671a78f638179c8951c9932061fd2bb348313a2c Mon Sep 17 00:00:00 2001 From: Sander Bosma Date: Mon, 20 Feb 2023 11:47:21 +0100 Subject: [PATCH] refactor Unsupported error to take rpc & arg --- client/src/client.rs | 2 +- client/src/error.rs | 8 ++++---- integration_test/src/main.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/client.rs b/client/src/client.rs index 6dd6d338..378624c1 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -290,7 +290,7 @@ pub trait RpcApi: Sized { if self.version()? < 210000 { // note: we allow Some(false) since it's the default behavior if let Some(true) = descriptors { - return Err(Error::Unsupported); + return Err(Error::UnsupportedArgument("createwallet", "descriptors")); } // no descriptors argument yet let mut args = [ diff --git a/client/src/error.rs b/client/src/error.rs index bb90cb3f..16a08901 100644 --- a/client/src/error.rs +++ b/client/src/error.rs @@ -31,8 +31,8 @@ pub enum Error { UnexpectedStructure, /// The daemon returned an error string. ReturnedError(String), - /// Feature not supported by the connected bitcoin version. - Unsupported, + /// The {0} RPC does not support the {1} argument on the connected bitcoin version. + UnsupportedArgument(&'static str, &'static str), } impl From for Error { @@ -90,8 +90,8 @@ impl fmt::Display for Error { Error::InvalidCookieFile => write!(f, "invalid cookie file"), Error::UnexpectedStructure => write!(f, "the JSON result had an unexpected structure"), Error::ReturnedError(ref s) => write!(f, "the daemon returned an error string: {}", s), - Error::Unsupported => { - write!(f, "the daemon version does not support the accessed feature") + Error::UnsupportedArgument(rpc, arg) => { + write!(f, "the daemon version does not support the {} argument for {}", arg, rpc) } } } diff --git a/integration_test/src/main.rs b/integration_test/src/main.rs index 04d477c3..7bd591eb 100644 --- a/integration_test/src/main.rs +++ b/integration_test/src/main.rs @@ -1285,7 +1285,7 @@ fn test_getblocktemplate(cl: &Client) { } fn test_unloadwallet(cl: &Client) { - cl.create_wallet("testunloadwallet", None, None, None, None).unwrap(); + cl.create_wallet("testunloadwallet", None, None, None, None, None).unwrap(); let res = new_wallet_client("testunloadwallet") .unload_wallet(None) @@ -1303,7 +1303,7 @@ fn test_loadwallet(_: &Client) { let wallet_client = new_wallet_client(wallet_name); assert!(wallet_client.load_wallet(wallet_name).is_err()); - wallet_client.create_wallet(wallet_name, None, None, None, None).unwrap(); + wallet_client.create_wallet(wallet_name, None, None, None, None, None).unwrap(); assert!(wallet_client.load_wallet(wallet_name).is_err()); wallet_client.unload_wallet(None).unwrap(); @@ -1318,7 +1318,7 @@ fn test_backupwallet(_: &Client) { assert!(wallet_client.backup_wallet(None).is_err()); assert!(wallet_client.backup_wallet(Some(&backup_path)).is_err()); - wallet_client.create_wallet("testbackupwallet", None, None, None, None).unwrap(); + wallet_client.create_wallet("testbackupwallet", None, None, None, None, None).unwrap(); assert!(wallet_client.backup_wallet(None).is_err()); assert!(wallet_client.backup_wallet(Some(&backup_path)).is_ok()); }