Files
tuliprox/webui/src/error.rs
T
2025-06-27 18:46:15 +02:00

43 lines
932 B
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 ErrorInfo {
pub errors: HashMap<String, Vec<String>>,
}
/// Define all possible errors
#[derive(ThisError, Clone, Debug, PartialEq, Eq)]
pub enum Error {
/// 401
#[error("Unauthorized")]
Unauthorized,
/// 403
#[error("Forbidden")]
Forbidden,
/// 404
#[error("Not Found")]
NotFound,
/// 422
#[error("Unprocessable Entity: {0:?}")]
UnprocessableEntity(ErrorInfo),
/// 500
#[error("Internal Server Error")]
InternalServerError,
/// serde deserialize error
#[error("Deserialize Error")]
DeserializeError,
/// request error
#[error("Http Request Error")]
RequestError,
}