1use std::{fmt::Display, error::Error};
2
3#[derive(Debug)]
4pub enum UpcloudError {
5 Reqwest(reqwest::Error),
6 Api(String),
7 Json(),
8}
9
10impl From<reqwest::Error> for UpcloudError {
11 fn from(value: reqwest::Error) -> Self {
12 UpcloudError::Reqwest(value)
13 }
14}
15
16impl Display for UpcloudError {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
18 match self {
19 UpcloudError::Reqwest(err) => write!(f, "Request: {}", err),
20 UpcloudError::Api(err) => write!(f, "Api: {}", err),
21 UpcloudError::Json() => write!(f, "JSON"),
22 }
23 }
24}
25
26impl Error for UpcloudError {}