jellyfin_sdk/error.rs
1use reqwest::StatusCode;
2
3/// A crate-wide result type.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Errors returned by this SDK.
7#[derive(thiserror::Error, Debug)]
8pub enum Error {
9 /// Base URL could not be parsed or normalized.
10 #[error("invalid base url: {0}")]
11 InvalidBaseUrl(#[from] url::ParseError),
12
13 /// HTTP client error (transport, timeout, TLS, etc).
14 #[error(transparent)]
15 Http(#[from] reqwest::Error),
16
17 /// A non-success HTTP status with captured body (best-effort).
18 #[error("request failed with status {status}: {body}")]
19 Api {
20 /// HTTP status code.
21 status: StatusCode,
22 /// Response body captured as UTF-8 text (lossy).
23 body: String,
24 /// Parsed Retry-After header in seconds, if present.
25 retry_after_seconds: Option<u64>,
26 },
27
28 /// JSON decoding error.
29 #[error(transparent)]
30 Json(#[from] serde_json::Error),
31
32 /// I/O error (filesystem, etc).
33 #[error(transparent)]
34 Io(#[from] std::io::Error),
35
36 /// Invalid configuration provided to the client builder.
37 #[error("invalid configuration: {0}")]
38 InvalidConfig(&'static str),
39
40 /// A user-provided timecode string could not be parsed.
41 #[error("invalid timecode: {0}")]
42 InvalidTimecode(String),
43}