mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-08 22:55:54 +01:00
fix: Unknown Error response error
This commit is contained in:
@@ -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<ErrorResponse> for Error {
|
||||
fn from(err: ErrorResponse) -> Error {
|
||||
Self::UnknownErrorResponse(err)
|
||||
Self::UnknownErrorResponse(err.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String>,
|
||||
}
|
||||
|
||||
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<Self, serde_json::Error> {
|
||||
if let Ok(res) = serde_json::from_str::<ErrorResponse>(json) {
|
||||
|
||||
@@ -15,7 +15,6 @@ use crate::{Amount, SECP256K1};
|
||||
|
||||
impl Secret {
|
||||
pub fn from_xpriv(xpriv: ExtendedPrivKey, keyset_id: Id, counter: u32) -> Result<Self, Error> {
|
||||
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<Self, Error> {
|
||||
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)?);
|
||||
|
||||
Reference in New Issue
Block a user