Skip to main content

neptunium_http/
error.rs

1use neptunium_model::time::duration::{Duration, representation::Seconds};
2use serde::Deserialize;
3
4use crate::error::{error_code::ApiErrorCode, validation_error_code::ApiValidationErrorCode};
5
6pub mod error_code;
7pub mod validation_error_code;
8
9#[derive(Deserialize, Clone, Debug)]
10pub struct ApiErrorEntry {
11    pub path: String,
12    pub message: String,
13    pub code: ApiValidationErrorCode,
14}
15
16#[derive(Deserialize, Clone, Debug)]
17pub struct ApiErrorResponse {
18    pub code: ApiErrorCode,
19    // I will assume that this field is always present
20    // -> need to check further though, to be sure
21    // https://github.com/fluxerapp/fluxer/blob/5da26d4ed5ef9f3fe8bef993c0f10ea4f4ee9c1d/packages/errors/src/HttpErrors.tsx#L24
22    pub message: String,
23    #[serde(default = "Vec::new")]
24    pub errors: Vec<ApiErrorEntry>,
25}
26
27#[derive(Deserialize, Clone, Debug)]
28pub struct ApiRateLimitedResponse {
29    /// Is always `RateLimited`.
30    pub code: ApiErrorCode,
31    pub message: String,
32    pub retry_after: Duration<Seconds>,
33    pub global: bool,
34}