torrust_tracker/console/clients/http/
mod.rs1use std::sync::Arc;
2
3use serde::Serialize;
4use thiserror::Error;
5
6use crate::shared::bit_torrent::tracker::http::client::responses::scrape::BencodeParseError;
7
8pub mod app;
9
10#[derive(Debug, Clone, Error, Serialize)]
11#[serde(into = "String")]
12pub enum Error {
13 #[error("Http request did not receive a response within the timeout: {err:?}")]
14 HttpClientError {
15 err: crate::shared::bit_torrent::tracker::http::client::Error,
16 },
17 #[error("Http failed to get a response at all: {err:?}")]
18 ResponseError { err: Arc<reqwest::Error> },
19 #[error("Failed to deserialize the bencoded response data with the error: \"{err:?}\"")]
20 ParseBencodeError {
21 data: hyper::body::Bytes,
22 err: Arc<serde_bencode::Error>,
23 },
24
25 #[error("Failed to deserialize the bencoded response data with the error: \"{err:?}\"")]
26 BencodeParseError {
27 data: hyper::body::Bytes,
28 err: Arc<BencodeParseError>,
29 },
30}
31
32impl From<Error> for String {
33 fn from(value: Error) -> Self {
34 value.to_string()
35 }
36}