Skip to content

Commit

Permalink
refactor Unsupported error to take rpc & arg
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed Jul 19, 2023
1 parent e51c69c commit d314293
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
8 changes: 4 additions & 4 deletions client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<jsonrpc::error::Error> for Error {
Expand Down Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit d314293

Please sign in to comment.