Skip to content

Commit 671a78f

Browse files
committed
refactor Unsupported error to take rpc & arg
1 parent e51c69c commit 671a78f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

client/src/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub trait RpcApi: Sized {
290290
if self.version()? < 210000 {
291291
// note: we allow Some(false) since it's the default behavior
292292
if let Some(true) = descriptors {
293-
return Err(Error::Unsupported);
293+
return Err(Error::UnsupportedArgument("createwallet", "descriptors"));
294294
}
295295
// no descriptors argument yet
296296
let mut args = [

client/src/error.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ pub enum Error {
3131
UnexpectedStructure,
3232
/// The daemon returned an error string.
3333
ReturnedError(String),
34-
/// Feature not supported by the connected bitcoin version.
35-
Unsupported,
34+
/// The {0} RPC does not support the {1} argument on the connected bitcoin version.
35+
UnsupportedArgument(&'static str, &'static str),
3636
}
3737

3838
impl From<jsonrpc::error::Error> for Error {
@@ -90,8 +90,8 @@ impl fmt::Display for Error {
9090
Error::InvalidCookieFile => write!(f, "invalid cookie file"),
9191
Error::UnexpectedStructure => write!(f, "the JSON result had an unexpected structure"),
9292
Error::ReturnedError(ref s) => write!(f, "the daemon returned an error string: {}", s),
93-
Error::Unsupported => {
94-
write!(f, "the daemon version does not support the accessed feature")
93+
Error::UnsupportedArgument(rpc, arg) => {
94+
write!(f, "the daemon version does not support the {} argument for {}", arg, rpc)
9595
}
9696
}
9797
}

integration_test/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ fn test_getblocktemplate(cl: &Client) {
12851285
}
12861286

12871287
fn test_unloadwallet(cl: &Client) {
1288-
cl.create_wallet("testunloadwallet", None, None, None, None).unwrap();
1288+
cl.create_wallet("testunloadwallet", None, None, None, None, None).unwrap();
12891289

12901290
let res = new_wallet_client("testunloadwallet")
12911291
.unload_wallet(None)
@@ -1303,7 +1303,7 @@ fn test_loadwallet(_: &Client) {
13031303
let wallet_client = new_wallet_client(wallet_name);
13041304

13051305
assert!(wallet_client.load_wallet(wallet_name).is_err());
1306-
wallet_client.create_wallet(wallet_name, None, None, None, None).unwrap();
1306+
wallet_client.create_wallet(wallet_name, None, None, None, None, None).unwrap();
13071307
assert!(wallet_client.load_wallet(wallet_name).is_err());
13081308
wallet_client.unload_wallet(None).unwrap();
13091309

@@ -1318,7 +1318,7 @@ fn test_backupwallet(_: &Client) {
13181318

13191319
assert!(wallet_client.backup_wallet(None).is_err());
13201320
assert!(wallet_client.backup_wallet(Some(&backup_path)).is_err());
1321-
wallet_client.create_wallet("testbackupwallet", None, None, None, None).unwrap();
1321+
wallet_client.create_wallet("testbackupwallet", None, None, None, None, None).unwrap();
13221322
assert!(wallet_client.backup_wallet(None).is_err());
13231323
assert!(wallet_client.backup_wallet(Some(&backup_path)).is_ok());
13241324
}

0 commit comments

Comments
 (0)