steamr/
errors.rs

1//! Custom error types
2
3use reqwest::Error;
4use thiserror::Error;
5
6/// Represents an error that was returned by a Steam API endpoint.
7#[derive(Debug, Error)]
8#[non_exhaustive]
9pub enum SteamError {
10    /// A reqwest failed for some reason
11    #[error("Error response from steam: {0}")]
12    FailedRequest(String),
13    /// The requested data is either private, or not present at all. Usually, this comes from a
14    /// deserialization error in serde.
15    #[error("The data you requested is either private or empty")]
16    NoData,
17}
18
19impl From<reqwest::Error> for SteamError {
20    fn from(err: Error) -> Self {
21        // If the reqwest goes wrong, we should forward it to the user
22        let reqwest_error = err.to_string();
23        Self::FailedRequest(reqwest_error)
24    }
25}