refactor(core): add ImageProcessingFailed error
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use axum::{http::StatusCode, response::IntoResponse, Json};
|
||||
use rocket::http::Status;
|
||||
|
||||
use crate::{Error, ErrorType};
|
||||
|
||||
@@ -78,6 +79,7 @@ impl IntoResponse for Error {
|
||||
ErrorType::FileTooSmall => StatusCode::UNPROCESSABLE_ENTITY,
|
||||
ErrorType::FileTooLarge { .. } => StatusCode::UNPROCESSABLE_ENTITY,
|
||||
ErrorType::FileTypeNotAllowed => StatusCode::BAD_REQUEST,
|
||||
ErrorType::ImageProcessingFailed => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
};
|
||||
|
||||
(status, Json(&self)).into_response()
|
||||
|
||||
@@ -162,6 +162,7 @@ pub enum ErrorType {
|
||||
max: usize,
|
||||
},
|
||||
FileTypeNotAllowed,
|
||||
ImageProcessingFailed,
|
||||
|
||||
// ? Legacy errors
|
||||
VosoUnavailable,
|
||||
|
||||
@@ -84,6 +84,7 @@ impl<'r> Responder<'r, 'static> for Error {
|
||||
ErrorType::FileTooSmall => Status::UnprocessableEntity,
|
||||
ErrorType::FileTooLarge { .. } => Status::UnprocessableEntity,
|
||||
ErrorType::FileTypeNotAllowed => Status::BadRequest,
|
||||
ErrorType::ImageProcessingFailed => Status::InternalServerError,
|
||||
};
|
||||
|
||||
// Serialize the error data structure into JSON.
|
||||
|
||||
Reference in New Issue
Block a user