From e1e747735a87b76125855e387c51f8c0feabf481 Mon Sep 17 00:00:00 2001 From: Dev Uni Date: Fri, 1 Dec 2023 00:58:54 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20MaxUploadSizeExceededException=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EB=8D=98=EC=A7=80=EA=B8=B0=20(#212)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../error/handler/GlobalExceptionHandler.java | 13 ++++++++++++- src/main/resources/config | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/moabam/global/error/handler/GlobalExceptionHandler.java b/src/main/java/com/moabam/global/error/handler/GlobalExceptionHandler.java index d45037c4..4d68a475 100644 --- a/src/main/java/com/moabam/global/error/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/moabam/global/error/handler/GlobalExceptionHandler.java @@ -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; @@ -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; @@ -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); + } } diff --git a/src/main/resources/config b/src/main/resources/config index 4dbde487..c9c58dc4 160000 --- a/src/main/resources/config +++ b/src/main/resources/config @@ -1 +1 @@ -Subproject commit 4dbde487226312c2a144165aa28c0cc0b1e7a0bf +Subproject commit c9c58dc4c9fbcd88ca2ae51e09b883e296bd3db9