From 9db5cc82f8924338cc0f4225716a199757a3226f Mon Sep 17 00:00:00 2001 From: asonix Date: Mon, 19 Feb 2024 12:55:44 -0600 Subject: [PATCH] Add special handling for FileSize errors --- src/error.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/error.rs b/src/error.rs index 7a77f5b..d107a9c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -166,6 +166,7 @@ pub(crate) enum UploadError { impl UploadError { const fn error_code(&self) -> ErrorCode { match self { + Self::Upload(actix_form_data::Error::FileSize) => ErrorCode::VALIDATE_FILE_SIZE, Self::Upload(_) => ErrorCode::FILE_UPLOAD_ERROR, Self::Repo(e) => e.error_code(), Self::OldRepo(_) => ErrorCode::OLD_REPO_ERROR, @@ -232,6 +233,10 @@ impl From for UploadError { impl ResponseError for Error { fn status_code(&self) -> StatusCode { match self.kind() { + Some(UploadError::Upload(actix_form_data::Error::FileSize)) + | Some(UploadError::Validation(crate::validate::ValidationError::Filesize)) => { + StatusCode::PAYLOAD_TOO_LARGE + } Some( UploadError::DuplicateAlias | UploadError::Limit(_)