blyss_rs/
error.rs

1use thiserror::Error;
2
3/// Error type for Blyss.
4#[derive(Error, Debug)]
5pub enum Error {
6    /// An error returned by the API.
7    #[error("Error returned by the API: status code {0} on path {1}")]
8    ApiError(String, String),
9    /// An error parsing or processing JSON.
10    #[error("JSON error: {0}")]
11    JsonError(#[from] serde_json::Error),
12    /// An error parsing or processing UTF-8.
13    #[error("UTF8 error: {0}")]
14    Utf8Error(#[from] std::str::Utf8Error),
15    /// An error parsing or processing UTF-8.
16    #[error("UTF8 error: {0}")]
17    FromUtf8Error(#[from] std::string::FromUtf8Error),
18    /// An error parsing or processing Base64.
19    #[error("Base64 error: {0}")]
20    Base64Error(#[from] base64::DecodeError),
21    /// An error making HTTP requests.
22    #[error("HTTP error: {0}")]
23    HTTPError(#[from] reqwest::Error),
24    /// A wrapped io::Error.
25    #[error("IO error: {0}")]
26    IOError(#[from] std::io::Error),
27    /// An error caused by failing to call `setup()` before using `private_read()`.
28    #[error("Must call setup() before using private_read()")]
29    NeedSetup,
30    /// An unknown error.
31    #[error("Unknown error")]
32    Unknown,
33}