tosho_amap/models/errors.rs
1//! A module containing all the errors used in the library.
2//!
3//! If something is missing, please [open an issue](https://github.com/noaione/tosho-mango/issues/new/choose) or a [pull request](https://github.com/noaione/tosho-mango/compare).
4
5use tosho_common::{ToshoError, make_error};
6
7/// The used error type for the API.
8#[derive(Debug, Clone)]
9pub struct AMAPIError {
10 /// The error message from the API.
11 pub message: String,
12}
13
14impl std::fmt::Display for AMAPIError {
15 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16 write!(f, "An error occurred: {}", self.message)
17 }
18}
19
20impl std::error::Error for AMAPIError {}
21
22impl From<AMAPIError> for ToshoError {
23 fn from(e: AMAPIError) -> Self {
24 make_error!("{}", e)
25 }
26}