mollie_api/models/
error_response.rs

1use core::fmt;
2use std::collections::HashMap;
3
4use serde::{Deserialize, Serialize};
5
6use super::link::Link;
7
8/// Model used to represent [error responses from the Mollie API](https://docs.mollie.com/overview/handling-errors#id2).
9#[derive(Debug, Deserialize, Serialize)]
10pub struct ErrorResponse {
11    /// [Http status code](https://docs.mollie.com/overview/handling-errors#all-possible-status-codes)
12    pub status: u16,
13
14    /// Error title
15    pub title: String,
16
17    /// More detailed error message
18    pub detail: String,
19
20    /// List of links to relevant documentation
21    #[serde(rename(deserialize = "_links"))]
22    pub links: HashMap<String, Link>,
23}
24
25impl fmt::Display for ErrorResponse {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        write!(
28            f,
29            "{}",
30            serde_json::to_string(&self).unwrap_or("Response error".to_string())
31        )
32    }
33}