2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 11:21:24 +00:00

Add special handling for FileSize errors

This commit is contained in:
asonix 2024-02-19 12:55:44 -06:00
parent 4d2c642c79
commit 9db5cc82f8

View file

@ -166,6 +166,7 @@ pub(crate) enum UploadError {
impl UploadError { impl UploadError {
const fn error_code(&self) -> ErrorCode { const fn error_code(&self) -> ErrorCode {
match self { match self {
Self::Upload(actix_form_data::Error::FileSize) => ErrorCode::VALIDATE_FILE_SIZE,
Self::Upload(_) => ErrorCode::FILE_UPLOAD_ERROR, Self::Upload(_) => ErrorCode::FILE_UPLOAD_ERROR,
Self::Repo(e) => e.error_code(), Self::Repo(e) => e.error_code(),
Self::OldRepo(_) => ErrorCode::OLD_REPO_ERROR, Self::OldRepo(_) => ErrorCode::OLD_REPO_ERROR,
@ -232,6 +233,10 @@ impl From<crate::store::StoreError> for UploadError {
impl ResponseError for Error { impl ResponseError for Error {
fn status_code(&self) -> StatusCode { fn status_code(&self) -> StatusCode {
match self.kind() { match self.kind() {
Some(UploadError::Upload(actix_form_data::Error::FileSize))
| Some(UploadError::Validation(crate::validate::ValidationError::Filesize)) => {
StatusCode::PAYLOAD_TOO_LARGE
}
Some( Some(
UploadError::DuplicateAlias UploadError::DuplicateAlias
| UploadError::Limit(_) | UploadError::Limit(_)