speedrun_api/
error.rs

1//! Error types for the crate
2use thiserror::Error;
3
4use crate::{api, AuthError};
5
6/// An alias for result types returned by this crate.
7pub type SpeedrunApiResult<T> = Result<T, SpeedrunApiError>;
8
9/// Errors from the speedrun.com api client.
10#[derive(Debug, Error)]
11#[non_exhaustive]
12pub enum SpeedrunApiError {
13    /// Error from the speedrun.com API
14    #[error("API error: {0}")]
15    Api(#[from] api::ApiError<RestError>),
16    /// Error parsing URL
17    #[error("url parse error: {0}")]
18    Parse(#[from] url::ParseError),
19}
20
21/// Error communicating with the REST endpoint.
22#[derive(Debug, Error)]
23#[non_exhaustive]
24pub enum RestError {
25    /// Reqwest client error
26    #[error("communication: {0}")]
27    Communication(#[from] reqwest::Error),
28    /// HTTP protocol error
29    #[error("HTTP error: {0}")]
30    Http(#[from] http::Error),
31    /// Authentication error
32    #[error("Authentication error: {0}")]
33    Authentication(#[from] AuthError),
34}