1use std::fmt::Display;
5
6use crate::FetchResponse;
7
8#[derive(Clone, Debug, PartialEq, Eq)]
10pub enum InternalError {
11 HyperError,
13
14 SynchronizationFault,
16}
17
18impl Display for InternalError {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 core::fmt::Debug::fmt(&self, f)
21 }
22}
23
24#[derive(Clone, Debug, PartialEq, Eq)]
26pub enum Error {
27 NetworkError(NetworkError),
29
30 InternalError(InternalError),
32}
33
34impl Display for Error {
35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 core::fmt::Debug::fmt(&self, f)
37 }
38}
39
40impl std::error::Error for Error {
41}
42
43#[derive(Clone, Debug, PartialEq, Eq)]
45pub enum NetworkError {
46 Generic,
48
49 LocalFileNotFound,
51}
52
53impl Display for NetworkError {
54 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55 core::fmt::Debug::fmt(&self, f)
56 }
57}
58
59impl From<InternalError> for FetchResponse {
60 fn from(value: InternalError) -> Self {
61 Err(value.into())
62 }
63}
64
65impl From<hyper::Error> for Error {
66 fn from(value: hyper::Error) -> Self {
67 _ = value;
69 Error::NetworkError(NetworkError::Generic)
70 }
71}
72
73impl From<InternalError> for Error {
74 fn from(value: InternalError) -> Self {
75 Self::InternalError(value)
76 }
77}
78
79impl From<Error> for FetchResponse {
80 fn from(value: Error) -> Self {
81 Err(value)
82 }
83}