From 308df7f45e887fb0aa7a578caccc8adec76286b7 Mon Sep 17 00:00:00 2001 From: lemone Date: Tue, 12 Nov 2024 14:31:38 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20member=20handler=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MemberExceptionHandler.java | 18 ++++++++++++++++++ .../controller/error/MemberApiError.java | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/site/coduo/member/controller/MemberExceptionHandler.java b/backend/src/main/java/site/coduo/member/controller/MemberExceptionHandler.java index 767dd64f..2cd7f65e 100644 --- a/backend/src/main/java/site/coduo/member/controller/MemberExceptionHandler.java +++ b/backend/src/main/java/site/coduo/member/controller/MemberExceptionHandler.java @@ -9,8 +9,10 @@ import lombok.extern.slf4j.Slf4j; import site.coduo.common.controller.response.ApiErrorResponse; import site.coduo.member.controller.error.MemberApiError; +import site.coduo.member.exception.AuthenticationException; import site.coduo.member.exception.ExternalApiCallException; import site.coduo.member.exception.InvalidMemberAddException; +import site.coduo.member.exception.MemberException; import site.coduo.member.exception.MemberNotFoundException; @Slf4j @@ -41,4 +43,20 @@ public ResponseEntity handlerExternalApiCallFailureException(f return ResponseEntity.status(MemberApiError.API_CALL_FAILURE_ERROR.getHttpStatus()) .body(new ApiErrorResponse(MemberApiError.MEMBER_NOT_FOUND_ERROR.getMessage())); } + + @ExceptionHandler(AuthenticationException.class) + public ResponseEntity handlerAuthenticationException(final AuthenticationException e) { + log.error(e.getMessage()); + + return ResponseEntity.status(MemberApiError.AUTHENTICATION_ERROR.getHttpStatus()) + .body(new ApiErrorResponse(MemberApiError.AUTHENTICATION_ERROR.getMessage())); + } + + @ExceptionHandler(MemberException.class) + public ResponseEntity handlerMemberException(final MemberException e) { + log.error(e.getMessage()); + + return ResponseEntity.status(MemberApiError.INVALID_MEMBER_REQUEST.getHttpStatus()) + .body(new ApiErrorResponse(MemberApiError.INVALID_MEMBER_REQUEST.getMessage())); + } } diff --git a/backend/src/main/java/site/coduo/member/controller/error/MemberApiError.java b/backend/src/main/java/site/coduo/member/controller/error/MemberApiError.java index 320976d0..8847dc39 100644 --- a/backend/src/main/java/site/coduo/member/controller/error/MemberApiError.java +++ b/backend/src/main/java/site/coduo/member/controller/error/MemberApiError.java @@ -12,7 +12,8 @@ public enum MemberApiError { AUTHENTICATION_ERROR(HttpStatus.UNAUTHORIZED, "인증되지 않은 접근입니다."), MEMBER_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "존재하지 않는 회원입니다."), INVALID_ADD_MEMBER_ERROR(HttpStatus.BAD_REQUEST, "자신의 아이디로 페어 정보 연동을 할 수 없습니다."), - API_CALL_FAILURE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "외부 API와 상호작용 중 실패했습니다."); + API_CALL_FAILURE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "외부 API와 상호작용 중 실패했습니다."), + INVALID_MEMBER_REQUEST(HttpStatus.BAD_REQUEST, "유효하지 않은 사용자 관련 요청입니다."); private final HttpStatus httpStatus; private final String message; From 7a7541cf815d24478bb8697adcd1ecea8236db6d Mon Sep 17 00:00:00 2001 From: lemone Date: Tue, 12 Nov 2024 14:33:14 +0900 Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20=ED=8E=98=EC=96=B4=EB=A3=B8=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=83=81=EC=88=98=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coduo/pairroom/controller/PairRoomExceptionHandler.java | 4 ++-- .../coduo/pairroom/controller/error/PairRoomApiError.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/site/coduo/pairroom/controller/PairRoomExceptionHandler.java b/backend/src/main/java/site/coduo/pairroom/controller/PairRoomExceptionHandler.java index 5116261c..6cc4019a 100644 --- a/backend/src/main/java/site/coduo/pairroom/controller/PairRoomExceptionHandler.java +++ b/backend/src/main/java/site/coduo/pairroom/controller/PairRoomExceptionHandler.java @@ -88,7 +88,7 @@ public ResponseEntity handlePairRoomMemberNotFoundException( public ResponseEntity handlePairRoomException(final PairRoomException e) { log.warn(e.getMessage()); - return ResponseEntity.status(PairRoomApiError.INVALID_REQUEST.getHttpStatus()) - .body(new ApiErrorResponse(PairRoomApiError.INVALID_REQUEST.getMessage())); + return ResponseEntity.status(PairRoomApiError.INVALID_PAIR_ROOM_REQUEST.getHttpStatus()) + .body(new ApiErrorResponse(PairRoomApiError.INVALID_PAIR_ROOM_REQUEST.getMessage())); } } diff --git a/backend/src/main/java/site/coduo/pairroom/controller/error/PairRoomApiError.java b/backend/src/main/java/site/coduo/pairroom/controller/error/PairRoomApiError.java index 30d36ce3..8c6d0ac0 100644 --- a/backend/src/main/java/site/coduo/pairroom/controller/error/PairRoomApiError.java +++ b/backend/src/main/java/site/coduo/pairroom/controller/error/PairRoomApiError.java @@ -9,7 +9,7 @@ @RequiredArgsConstructor public enum PairRoomApiError { - INVALID_REQUEST(HttpStatus.BAD_REQUEST, "유효하지 않은 요청입니다."), + INVALID_PAIR_ROOM_REQUEST(HttpStatus.BAD_REQUEST, "유효하지 않은 페어룸 관련 요청입니다."), INVALID_PAIR_NAME(HttpStatus.BAD_REQUEST, "올바르지 않은 페어 이름입니다."), INVALID_ACCESS_CODE(HttpStatus.BAD_REQUEST, "올바르지 않은 접근 코드입니다."), PAIR_ROOM_NOT_FOUND(HttpStatus.NOT_FOUND, "페어룸이 존재하지 않습니다."), From e2aa437e5e37611b119f50129e83c94a90ea4fc2 Mon Sep 17 00:00:00 2001 From: lemone Date: Tue, 12 Nov 2024 14:34:40 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=EB=A0=88=ED=8D=BC=EB=9F=B0?= =?UTF-8?q?=EC=8A=A4=20=EB=A7=81=ED=81=AC=20=EC=98=88=EC=99=B8=20=ED=95=B8?= =?UTF-8?q?=EB=93=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReferenceLinkExceptionHandler.java | 18 ++++++++++++++++++ .../error/ReferenceLinkApiError.java | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/site/coduo/referencelink/controller/ReferenceLinkExceptionHandler.java b/backend/src/main/java/site/coduo/referencelink/controller/ReferenceLinkExceptionHandler.java index 411b7963..cca8e5ed 100644 --- a/backend/src/main/java/site/coduo/referencelink/controller/ReferenceLinkExceptionHandler.java +++ b/backend/src/main/java/site/coduo/referencelink/controller/ReferenceLinkExceptionHandler.java @@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j; import site.coduo.common.controller.response.ApiErrorResponse; import site.coduo.referencelink.controller.error.ReferenceLinkApiError; +import site.coduo.referencelink.exception.CategoryNotFoundException; +import site.coduo.referencelink.exception.InvalidCategoryException; import site.coduo.referencelink.exception.InvalidUrlFormatException; import site.coduo.referencelink.exception.ReferenceLinkException; @@ -25,6 +27,22 @@ public ResponseEntity handleInvalidUrlFormatException(final In .body(new ApiErrorResponse(ReferenceLinkApiError.INVALID_URL_FORMAT.getMessage())); } + @ExceptionHandler(CategoryNotFoundException.class) + public ResponseEntity handleCategoryNotFoundException(final CategoryNotFoundException e) { + log.warn(e.getMessage()); + + return ResponseEntity.status(ReferenceLinkApiError.CATEGORY_NOT_FOUND.getHttpStatus()) + .body(new ApiErrorResponse(ReferenceLinkApiError.CATEGORY_NOT_FOUND.getMessage())); + } + + @ExceptionHandler(InvalidCategoryException.class) + public ResponseEntity handleInvalidCategoryException(final InvalidCategoryException e) { + log.warn(e.getMessage()); + + return ResponseEntity.status(ReferenceLinkApiError.INVALID_CATEGORY_FORMAT.getHttpStatus()) + .body(new ApiErrorResponse(ReferenceLinkApiError.INVALID_CATEGORY_FORMAT.getMessage())); + } + @ExceptionHandler(ReferenceLinkException.class) public ResponseEntity handleReferenceLinkException(final ReferenceLinkException e) { log.warn(e.getMessage()); diff --git a/backend/src/main/java/site/coduo/referencelink/controller/error/ReferenceLinkApiError.java b/backend/src/main/java/site/coduo/referencelink/controller/error/ReferenceLinkApiError.java index 16c9878b..9fe94c06 100644 --- a/backend/src/main/java/site/coduo/referencelink/controller/error/ReferenceLinkApiError.java +++ b/backend/src/main/java/site/coduo/referencelink/controller/error/ReferenceLinkApiError.java @@ -11,7 +11,9 @@ public enum ReferenceLinkApiError { INVALID_URL_FORMAT(HttpStatus.BAD_REQUEST, "올바르지 않은 URL 형식입니다."), REFERENCE_LINK_NOT_FOUND(HttpStatus.NOT_FOUND, "링크 정보가 존재하지 않습니다."), - BAD_REQUEST(HttpStatus.BAD_REQUEST, "유효하지 않은 요청입니다."); + CATEGORY_NOT_FOUND(HttpStatus.NOT_FOUND, "카테고리를 찾을 수 없습니다."), + INVALID_CATEGORY_FORMAT(HttpStatus.BAD_REQUEST, "올바르지 않은 카테고리 형식입니다."), + BAD_REQUEST(HttpStatus.BAD_REQUEST, "유효하지 않은 카테고리 혹은 레퍼런스 링크 요청입니다."); private final HttpStatus httpStatus; private final String message; From fa8cda6613396833114779dc8b1274901db6cd2e Mon Sep 17 00:00:00 2001 From: lemone Date: Tue, 12 Nov 2024 14:35:34 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=ED=88=AC=EB=91=90=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=ED=95=B8=EB=93=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../todo/controller/TodoExceptionHandler.java | 30 ++++++++++++++++++- .../todo/controller/error/TodoApiError.java | 3 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/site/coduo/todo/controller/TodoExceptionHandler.java b/backend/src/main/java/site/coduo/todo/controller/TodoExceptionHandler.java index 89999859..7ef01763 100644 --- a/backend/src/main/java/site/coduo/todo/controller/TodoExceptionHandler.java +++ b/backend/src/main/java/site/coduo/todo/controller/TodoExceptionHandler.java @@ -9,18 +9,46 @@ import lombok.extern.slf4j.Slf4j; import site.coduo.common.controller.response.ApiErrorResponse; import site.coduo.todo.controller.error.TodoApiError; +import site.coduo.todo.exception.InvalidTodoContentException; +import site.coduo.todo.exception.InvalidUpdatedTodoSortException; import site.coduo.todo.exception.TodoException; +import site.coduo.todo.exception.TodoNotFoundException; @Slf4j @RestControllerAdvice @Order(Ordered.HIGHEST_PRECEDENCE) public class TodoExceptionHandler { + @ExceptionHandler(InvalidTodoContentException.class) + public ResponseEntity handleInvalidTodoContentException(final InvalidTodoContentException e) { + log.warn(e.getMessage()); + + return ResponseEntity.status(TodoApiError.INVALID_TODO_CONTENT_FORMAT.getHttpStatus()) + .body(new ApiErrorResponse(TodoApiError.INVALID_TODO_CONTENT_FORMAT.getMessage())); + } + + @ExceptionHandler(InvalidUpdatedTodoSortException.class) + public ResponseEntity handleInvalidUpdatedTodoSortException( + final InvalidUpdatedTodoSortException e) { + log.warn(e.getMessage()); + + return ResponseEntity.status(TodoApiError.INVALID_TODO_SORT.getHttpStatus()) + .body(new ApiErrorResponse(TodoApiError.INVALID_TODO_SORT.getMessage())); + } + + @ExceptionHandler(TodoNotFoundException.class) + public ResponseEntity handleTodoNotFoundException(final TodoNotFoundException e) { + log.warn(e.getMessage()); + + return ResponseEntity.status(TodoApiError.TODO_NOT_FOUND.getHttpStatus()) + .body(new ApiErrorResponse(TodoApiError.TODO_NOT_FOUND.getMessage())); + } + @ExceptionHandler(TodoException.class) public ResponseEntity handleTodoException(final TodoException e) { log.warn(e.getMessage()); return ResponseEntity.status(TodoApiError.INVALID_TODO_REQUEST.getHttpStatus()) - .body(new ApiErrorResponse(e.getMessage())); + .body(new ApiErrorResponse(TodoApiError.INVALID_TODO_REQUEST.getMessage())); } } diff --git a/backend/src/main/java/site/coduo/todo/controller/error/TodoApiError.java b/backend/src/main/java/site/coduo/todo/controller/error/TodoApiError.java index e3a88619..9a245c09 100644 --- a/backend/src/main/java/site/coduo/todo/controller/error/TodoApiError.java +++ b/backend/src/main/java/site/coduo/todo/controller/error/TodoApiError.java @@ -9,6 +9,9 @@ @RequiredArgsConstructor public enum TodoApiError { + TODO_NOT_FOUND(HttpStatus.NOT_FOUND, "투두를 찾을 수 없습니다."), + INVALID_TODO_SORT(HttpStatus.BAD_REQUEST, "유효하지 않은 투두 순서입니다."), + INVALID_TODO_CONTENT_FORMAT(HttpStatus.BAD_REQUEST, "유효하지 않은 투두 내용 형식입니다."), INVALID_TODO_REQUEST(HttpStatus.BAD_REQUEST, "유효하지 않은 TODO 요청입니다."); private final HttpStatus httpStatus; From 8a0921980b26e0f2b631ec4900ab72feb1c4fd00 Mon Sep 17 00:00:00 2001 From: lemone Date: Tue, 12 Nov 2024 14:36:01 +0900 Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BB=A4=EC=8A=A4=ED=85=80=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EB=B0=8F=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coduo/retrospect/exception/RetrospectException.java | 4 ---- .../site/coduo/timer/exception/NegativeTimeException.java | 8 -------- .../todo/exception/InvalidTodoArgumentException.java | 8 -------- 3 files changed, 20 deletions(-) delete mode 100644 backend/src/main/java/site/coduo/timer/exception/NegativeTimeException.java delete mode 100644 backend/src/main/java/site/coduo/todo/exception/InvalidTodoArgumentException.java diff --git a/backend/src/main/java/site/coduo/retrospect/exception/RetrospectException.java b/backend/src/main/java/site/coduo/retrospect/exception/RetrospectException.java index 6f256c62..ca868576 100644 --- a/backend/src/main/java/site/coduo/retrospect/exception/RetrospectException.java +++ b/backend/src/main/java/site/coduo/retrospect/exception/RetrospectException.java @@ -5,8 +5,4 @@ public class RetrospectException extends RuntimeException { public RetrospectException(final String message) { super(message); } - - public RetrospectException(final String message, final Throwable cause) { - super(message, cause); - } } diff --git a/backend/src/main/java/site/coduo/timer/exception/NegativeTimeException.java b/backend/src/main/java/site/coduo/timer/exception/NegativeTimeException.java deleted file mode 100644 index c6b76f87..00000000 --- a/backend/src/main/java/site/coduo/timer/exception/NegativeTimeException.java +++ /dev/null @@ -1,8 +0,0 @@ -package site.coduo.timer.exception; - -public class NegativeTimeException extends TimerException{ - - public NegativeTimeException(final String message) { - super(message); - } -} diff --git a/backend/src/main/java/site/coduo/todo/exception/InvalidTodoArgumentException.java b/backend/src/main/java/site/coduo/todo/exception/InvalidTodoArgumentException.java deleted file mode 100644 index c4a771cf..00000000 --- a/backend/src/main/java/site/coduo/todo/exception/InvalidTodoArgumentException.java +++ /dev/null @@ -1,8 +0,0 @@ -package site.coduo.todo.exception; - -public class InvalidTodoArgumentException extends TodoException { - - public InvalidTodoArgumentException(final String message) { - super(message); - } -}