diff --git a/crates/cdk/src/client.rs b/crates/cdk/src/client.rs index cd309f3f..a95dcde7 100644 --- a/crates/cdk/src/client.rs +++ b/crates/cdk/src/client.rs @@ -27,14 +27,14 @@ pub enum Error { /// From hex error #[error(transparent)] ReqwestError(#[from] reqwest::Error), - /// Min req error - #[error("Unknown Error response")] - UnknownErrorResponse(crate::error::ErrorResponse), + /// Unknown error response + #[error("Unknown Error response: `{0}`")] + UnknownErrorResponse(String), } impl From for Error { fn from(err: ErrorResponse) -> Error { - Self::UnknownErrorResponse(err) + Self::UnknownErrorResponse(err.to_string()) } } diff --git a/crates/cdk/src/error.rs b/crates/cdk/src/error.rs index 272c8594..3ed3ad85 100644 --- a/crates/cdk/src/error.rs +++ b/crates/cdk/src/error.rs @@ -1,5 +1,6 @@ //! Errors +use std::fmt; use std::string::FromUtf8Error; use serde::{Deserialize, Serialize}; @@ -82,6 +83,18 @@ pub struct ErrorResponse { pub detail: Option, } +impl fmt::Display for ErrorResponse { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "code: {}, error: {}, detail: {}", + self.code, + self.error.clone().unwrap_or_default(), + self.detail.clone().unwrap_or_default() + ) + } +} + impl ErrorResponse { pub fn from_json(json: &str) -> Result { if let Ok(res) = serde_json::from_str::(json) { diff --git a/crates/cdk/src/nuts/nut13.rs b/crates/cdk/src/nuts/nut13.rs index efb4f7a0..b4522939 100644 --- a/crates/cdk/src/nuts/nut13.rs +++ b/crates/cdk/src/nuts/nut13.rs @@ -15,7 +15,6 @@ use crate::{Amount, SECP256K1}; impl Secret { pub fn from_xpriv(xpriv: ExtendedPrivKey, keyset_id: Id, counter: u32) -> Result { - tracing::debug!("Deriving secret for {} with count {}", keyset_id, counter); let path = derive_path_from_keyset_id(keyset_id)? .child(ChildNumber::from_hardened_idx(counter)?) .child(ChildNumber::from_normal_idx(0)?); @@ -29,7 +28,6 @@ impl Secret { impl SecretKey { pub fn from_xpriv(xpriv: ExtendedPrivKey, keyset_id: Id, counter: u32) -> Result { - tracing::debug!("Deriving key for {} with count {}", keyset_id, counter); let path = derive_path_from_keyset_id(keyset_id)? .child(ChildNumber::from_hardened_idx(counter)?) .child(ChildNumber::from_normal_idx(1)?);