streaming_http_range_client/
error.rs1use std::fmt::{Display, Formatter};
2
3#[derive(Debug)]
4pub enum Error {
5 HttpFailed { status: u16 },
6 IO(std::io::Error),
7 External(Box<dyn std::error::Error + Send + Sync + 'static>),
8}
9
10impl Display for Error {
11 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
12 match self {
13 Error::HttpFailed { status } => {
14 write!(f, "HTTP requests failed with status: {status}")
15 }
16 Error::IO(io) => io.fmt(f),
17 Error::External(external) => external.fmt(f),
18 }
19 }
20}
21
22impl std::error::Error for Error {}
23pub type Result<T> = std::result::Result<T, Error>;
24
25impl From<std::io::Error> for Error {
26 fn from(value: std::io::Error) -> Self {
27 Self::IO(value)
28 }
29}