Skip to content

Commit

Permalink
chore: MaxUploadSizeExceededException 중복 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
rheeri committed Nov 3, 2024
1 parent d119e3a commit e7526ec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
public enum AwsErrorCode implements ErrorCode {
AMAZON_S3_EXCEPTION(404, "Amazon S3 exception"),
AMAZON_SERVICE_EXCEPTION(500, "Amazon service exception"),
DELETE_OBJECT_EXCEPTION(500, "Failed to delete image to S3 due to an internal error"),
MAXIMUM_UPLOAD_SIZE_EXCEEDED(413, "Maximum upload size exceeded");
DELETE_OBJECT_EXCEPTION(500, "Failed to delete image to S3 due to an internal error");

private final int httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum CommonErrorCode implements ErrorCode {
RESOURCE_NOT_FOUND(404, "Resource not exists"),
INTERNAL_SERVER_ERROR(500, "Internal server error"),
IO_EXCEPTION(500, "IoException occurred"),
PAYLOAD_TOO_LARGE(413, "Payload too large");
MAXIMUM_UPLOAD_SIZE_EXCEEDED(413, "Maximum upload size exceeded");

private final int httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

import com.foru.freebe.errors.errorcode.AwsErrorCode;
import com.foru.freebe.errors.errorcode.CommonErrorCode;
import com.foru.freebe.errors.errorcode.ErrorCode;
import com.foru.freebe.errors.exception.JwtTokenException;
Expand Down Expand Up @@ -49,12 +48,6 @@ public ResponseEntity<Object> handleDataTruncation(DataTruncation e) {
return handleExceptionInternal(errorCode, message);
}

@ExceptionHandler(MaxUploadSizeExceededException.class)
public ResponseEntity<Object> handleMaxUploadSizeExceeded(MaxUploadSizeExceededException e) {
ErrorCode errorCode = CommonErrorCode.PAYLOAD_TOO_LARGE;
return handleExceptionInternal(errorCode, e.getMessage());
}

// 메서드 인자의 유효성 검사가 실패했을 때 발생
// 주로 Spring의 @Valid, @Validated 애노테이션을 사용한 검증 실패시 발생
@Override
Expand All @@ -67,7 +60,7 @@ public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotVali
@Override
public ResponseEntity<Object> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e,

Check warning on line 61 in src/main/java/com/foru/freebe/errors/handler/GlobalExceptionHandler.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

@NotNull/@Nullable problems

Not annotated parameter overrides @NonNullApi parameter
HttpHeaders headers, HttpStatusCode status, WebRequest request) {

Check warning on line 62 in src/main/java/com/foru/freebe/errors/handler/GlobalExceptionHandler.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

@NotNull/@Nullable problems

Not annotated parameter overrides @NonNullApi parameter

Check warning on line 62 in src/main/java/com/foru/freebe/errors/handler/GlobalExceptionHandler.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

@NotNull/@Nullable problems

Not annotated parameter overrides @NonNullApi parameter

Check warning on line 62 in src/main/java/com/foru/freebe/errors/handler/GlobalExceptionHandler.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

@NotNull/@Nullable problems

Not annotated parameter overrides @NonNullApi parameter
ErrorCode errorCode = AwsErrorCode.MAXIMUM_UPLOAD_SIZE_EXCEEDED;
ErrorCode errorCode = CommonErrorCode.MAXIMUM_UPLOAD_SIZE_EXCEEDED;
return handleExceptionInternal(e, errorCode);
}

Expand Down

0 comments on commit e7526ec

Please sign in to comment.