Forgot to add

This commit is contained in:
Даниил 2023-06-30 18:25:56 +04:00
parent 83d712b930
commit 427a3095f8
15 changed files with 1992 additions and 124 deletions

View file

@ -25,6 +25,11 @@ pub enum AppError {
#[error("Fuck")]
RequestTooLarge,
#[error("Api")]
ApiKeyInvalid {
reason: &'static str
},
#[error("Fuck")]
UnitValidationFailed {
max: Option<Decimal>,
@ -51,6 +56,9 @@ impl IntoResponse for AppError {
},
AppError::ServerRedisError(_) => {
(StatusCode::INTERNAL_SERVER_ERROR, "Internal server error")
},
AppError::ApiKeyInvalid { .. } => {
(StatusCode::BAD_REQUEST, "API Key invalid")
}
};
@ -76,6 +84,9 @@ impl IntoResponse for AppError {
AppError::RequestTooLarge => {
headers.insert("X-Max-Request-Size", HeaderValue::try_from("10 KiB = 10240 bytes").unwrap());
},
AppError::ApiKeyInvalid { reason } => {
headers.insert("X-Error-Description", HeaderValue::try_from(reason).unwrap());
},
_ => {}
};