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:
parent
4d2c642c79
commit
9db5cc82f8
1 changed files with 5 additions and 0 deletions
|
@ -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<crate::store::StoreError> 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(_)
|
||||
|
|
Loading…
Reference in a new issue