Skip to content

Commit

Permalink
fix: MaxUploadSizeExceededException 예외 던지기 (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shin-Jae-Yoon authored Nov 30, 2023
1 parent 90b33cd commit e1e7477
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.moabam.global.error.handler;

import static com.moabam.global.error.model.ErrorMessage.*;
import static com.moabam.global.error.model.ErrorMessage.INVALID_REQUEST_FIELD;
import static com.moabam.global.error.model.ErrorMessage.INVALID_REQUEST_VALUE_TYPE_FORMAT;
import static com.moabam.global.error.model.ErrorMessage.S3_INVALID_IMAGE_SIZE;

import java.util.HashMap;
import java.util.List;
Expand All @@ -14,6 +16,7 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

import com.moabam.global.error.exception.BadRequestException;
import com.moabam.global.error.exception.ConflictException;
Expand Down Expand Up @@ -99,4 +102,12 @@ public ErrorResponse handleMethodArgumentTypeMismatchException(MethodArgumentTyp

return new ErrorResponse(message, null);
}

@ExceptionHandler(MaxUploadSizeExceededException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorResponse handleMaxSizeException(MaxUploadSizeExceededException exception) {
String message = String.format(S3_INVALID_IMAGE_SIZE.getMessage());

return new ErrorResponse(message, null);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/config

0 comments on commit e1e7477

Please sign in to comment.