mirror of
https://github.com/euzu/tuliprox.git
synced 2026-09-30 21:12:12 +02:00
52 lines
1.1 KiB
Rust
52 lines
1.1 KiB
Rust
use std::collections::HashMap;
|
|
use serde::{Deserialize, Serialize};
|
|
use thiserror::Error as ThisError;
|
|
|
|
/// Conduit api error info for Unprocessable Entity error
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ErrorSetInfo {
|
|
pub errors: HashMap<String, Vec<String>>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ErrorInfo {
|
|
pub error: String,
|
|
}
|
|
|
|
/// Define all possible errors
|
|
#[derive(ThisError, Clone, Debug, PartialEq, Eq)]
|
|
pub enum Error {
|
|
/// 400
|
|
#[error("{0}")]
|
|
BadRequest(String),
|
|
|
|
/// 401
|
|
#[error("Unauthorized")]
|
|
Unauthorized,
|
|
|
|
/// 403
|
|
#[error("Forbidden")]
|
|
Forbidden,
|
|
|
|
/// 404
|
|
#[error("Not Found")]
|
|
NotFound,
|
|
|
|
/// 422
|
|
#[error("Unprocessable Entity: {0:?}")]
|
|
UnprocessableEntity(ErrorSetInfo),
|
|
|
|
/// 500
|
|
#[error("Internal Server Error")]
|
|
InternalServerError,
|
|
|
|
/// serde deserialize error
|
|
#[error("Deserialize Error")]
|
|
DeserializeError,
|
|
|
|
/// request error
|
|
#[error("Http Request Error")]
|
|
RequestError,
|
|
} |