1use thiserror::Error;
2
3
4#[derive(Debug, Error)]
5pub enum JupiterError {
6 #[error("network error: {0}")]
7 Network(String),
8
9 #[error("http error: status={status}, content_type={content_type:?}, body={body}")]
10 Http {
11 status: u16,
12 body: String,
13 content_type: Option<String>,
14 },
15
16 #[error("parse error at {path}: {message}. body={body}")]
17 Parse {
18 message: String,
19 path: String,
20 body: String,
21 },
22
23 #[error("internal error: {0}")]
24 Internal(String),
25}
26
27impl From<reqwest::Error> for JupiterError {
28 fn from(err: reqwest::Error) -> Self {
29 if err.is_timeout() {
30 JupiterError::Network("timeout".into())
31 } else {
32 JupiterError::Network(err.to_string())
33 }
34 }
35}
36
37