1use std::fmt::{Display, Formatter};
2
3use serde::{de::StdError, Deserialize, Serialize};
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum Error {
9 #[error("error: {:?}, code: {:?}, text: {:?}", .0.error, .0.status_code, .0.status_text)]
10 Auction(AuctionError),
11 #[error("failed to call api")]
12 Transport(#[from] reqwest::Error),
13 #[error(transparent)]
14 Parse(#[from] url::ParseError),
15 #[error("failed to init builder client")]
16 Init(String),
17}
18
19#[derive(Serialize, Deserialize, Clone, Debug)]
21pub struct AuctionError {
22 pub error: String,
23 pub status_code: u64,
24 pub status_text: String,
25}
26
27impl Display for AuctionError {
28 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29 write!(
30 f,
31 "error: {}, code: {}, text: {}",
32 self.error, self.status_code, self.status_text
33 )
34 }
35}
36
37impl StdError for AuctionError {}