1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum YukiError {
5 #[error("authentication failed: {0}")]
6 AuthFailed(String),
7
8 #[error("not found: {0}")]
9 NotFound(String),
10
11 #[error("rate limited: 1000 calls/day exceeded")]
12 RateLimited,
13
14 #[error("HTTP error {status}: {body}")]
15 Http { status: u16, body: String },
16
17 #[error("SOAP fault [{code}]: {message}")]
18 SoapFault { code: String, message: String },
19
20 #[error("configuration error: {0}")]
21 Config(String),
22
23 #[error("XML error: {0}")]
24 Xml(String),
25
26 #[error("{0}")]
27 Request(#[from] reqwest::Error),
28}
29
30impl YukiError {
31 pub fn exit_code(&self) -> u8 {
32 match self {
33 Self::AuthFailed(_) => 2,
34 Self::NotFound(_) => 3,
35 Self::RateLimited => 4,
36 _ => 1,
37 }
38 }
39}