Skip to content

Comments

[refactor] BusinessException 문자열 사용 제거 및 에러 로깅 개선#85

Merged
k3vin7 merged 3 commits intomainfrom
refactor/exception
Feb 21, 2026
Merged

[refactor] BusinessException 문자열 사용 제거 및 에러 로깅 개선#85
k3vin7 merged 3 commits intomainfrom
refactor/exception

Conversation

@k3vin7
Copy link
Contributor

@k3vin7 k3vin7 commented Feb 21, 2026

BusinessException에 문자열만 넘기던 패턴을 도메인별 에러코드로 교체하고, 로깅 개선

@gemini-code-assist
Copy link

Summary of Changes

Hello @k3vin7, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 애플리케이션 전반의 에러 처리 방식을 표준화하고 개선하기 위한 리팩토링입니다. 기존에 BusinessException에 직접 문자열을 사용하던 패턴을 도메인별 에러 코드로 대체하여 에러 메시지의 일관성을 확보하고, 에러 로깅을 강화하여 문제 발생 시 진단 효율성을 높였습니다. 이를 통해 코드의 유지보수성과 안정성이 향상될 것으로 기대됩니다.

Highlights

  • BusinessException 문자열 사용 제거: 기존에 BusinessException에 직접 문자열 메시지를 전달하던 방식을 각 도메인별 에러 코드(enum)를 사용하도록 변경하여 에러 처리의 일관성과 가독성을 높였습니다.
  • 도메인별 에러 코드 도입: Auth, Comment, Notification, Post, User 등 각 도메인에 특화된 에러 상태(예: AuthErrorStatus, CommentErrorStatus)를 새로 정의하고 적용했습니다.
  • 에러 로깅 개선: GlobalExceptionHandler에서 BusinessException 발생 시, 에러 코드의 메시지뿐만 아니라 실제 예외 메시지도 함께 로깅하도록 개선하여 디버깅에 유용한 정보를 추가했습니다.
  • .gitignore 업데이트: 보안 강화를 위해 .pem 파일을 .gitignore에 추가하여 민감한 파일이 실수로 커밋되는 것을 방지했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .gitignore
    • .pem 파일이 Git 추적에서 제외되도록 추가되었습니다.
  • src/main/java/com/daramg/server/auth/application/AuthService.java
    • 회원가입 시 중복 이메일/닉네임, 회원 탈퇴 시 비밀번호 불일치 예외 처리에서 BusinessException의 문자열 메시지가 AuthErrorStatus enum으로 대체되었습니다.
  • src/main/java/com/daramg/server/auth/application/MailVerificationServiceImpl.java
    • 이메일 발송 목적 미지원 및 이메일 변경 시 중복 이메일 예외 처리에서 BusinessException의 문자열 메시지가 AuthErrorStatus 또는 UserErrorStatus enum으로 대체되었습니다.
  • src/main/java/com/daramg/server/auth/exception/AuthErrorStatus.java
    • 인증 관련 에러 코드(DUPLICATE_EMAIL, DUPLICATE_NICKNAME, INVALID_PASSWORD, UNSUPPORTED_EMAIL_PURPOSE)가 추가되었습니다.
  • src/main/java/com/daramg/server/comment/application/CommentService.java
    • 댓글 생성, 대댓글 생성, 댓글 좋아요, 댓글 삭제 로직에서 BusinessException의 문자열 메시지가 CommentErrorStatus enum으로 대체되었습니다.
  • src/main/java/com/daramg/server/comment/exception/CommentErrorStatus.java
    • 댓글 관련 에러 코드(BLOCKED_POST, BLOCKED_OR_DELETED_COMMENT, ALREADY_DELETED, NOT_COMMENT_AUTHOR)가 추가되었습니다.
  • src/main/java/com/daramg/server/common/exception/CommonErrorStatus.java
    • 공통 에러 코드에 INVALID_CURSOR가 추가되었습니다.
  • src/main/java/com/daramg/server/common/exception/ErrorCategory.java
    • 에러 카테고리에 COMMENTNOTIFICATION이 추가되었습니다.
  • src/main/java/com/daramg/server/common/exception/GlobalExceptionHandler.java
    • BusinessException 처리 시 로깅 메시지에 실제 예외 메시지가 포함되도록 수정되었습니다.
  • src/main/java/com/daramg/server/common/util/PagingUtils.java
    • 커서 디코딩 실패 시 BusinessException의 문자열 메시지가 CommonErrorStatus.INVALID_CURSOR로 대체되었습니다.
  • src/main/java/com/daramg/server/notice/utils/NoticeUserValidator.java
    • 공지사항 작성자 불일치 예외 처리에서 BusinessException의 문자열 메시지가 NotificationErrorStatus.NOT_NOTICE_AUTHOR로 대체되었습니다.
  • src/main/java/com/daramg/server/notification/application/NotificationService.java
    • 알림 수신자 검증 실패 시 BusinessException의 문자열 메시지가 NotificationErrorStatus.NOT_OWN_NOTIFICATION으로 대체되었습니다.
  • src/main/java/com/daramg/server/notification/exception/NotificationErrorStatus.java
    • 알림 관련 에러 코드(NOT_OWN_NOTIFICATION, NOT_NOTICE_AUTHOR)가 추가되었습니다.
  • src/main/java/com/daramg/server/post/application/PostService.java
    • 포스트 발행 시 주요 작곡가 필수 예외 처리에서 BusinessException의 문자열 메시지가 PostErrorStatus.PRIMARY_COMPOSER_REQUIRED로 대체되었습니다.
  • src/main/java/com/daramg/server/post/exception/PostErrorStatus.java
    • 포스트 관련 에러 코드(PRIMARY_COMPOSER_REQUIRED, NOT_POST_AUTHOR)가 추가되었습니다.
  • src/main/java/com/daramg/server/post/utils/PostUserValidator.java
    • 포스트 작성자 불일치 예외 처리에서 BusinessException의 문자열 메시지가 PostErrorStatus.NOT_POST_AUTHOR로 대체되었습니다.
  • src/main/java/com/daramg/server/user/application/UserService.java
    • 사용자 이메일/비밀번호 변경, 프로필 업데이트, 팔로우/언팔로우, 회원 탈퇴 로직에서 BusinessException의 문자열 메시지가 UserErrorStatus enum으로 대체되었고, 사용되지 않는 import 문이 제거되었습니다.
  • src/main/java/com/daramg/server/user/exception/UserErrorStatus.java
    • 사용자 관련 에러 코드(USER_NOT_FOUND, SAME_EMAIL, DUPLICATE_EMAIL, SELF_FOLLOW, ALREADY_FOLLOWING, SELF_UNFOLLOW, NOT_FOLLOWING)가 추가되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

안녕하세요. 전반적으로 매우 훌륭한 리팩토링입니다! BusinessException에서 문자열을 직접 사용하던 부분을 도메인별 에러 코드로 대체하여 코드의 유지보수성과 일관성을 크게 향상시켰습니다. 또한 로깅을 개선하려는 노력도 좋습니다.

한 가지 제안 사항으로, GlobalExceptionHandler의 로그 메시지 형식을 조금 더 개선하면 중복을 줄이고 디버깅에 더 유용한 정보를 포함할 수 있을 것 같습니다. 관련하여 코드에 직접 코멘트를 남겼으니 확인 부탁드립니다.

수고 많으셨습니다!

BaseErrorCode errorCode = e.getErrorCode();

log.warn("GeneralException: {}", errorCode.getMessage());
log.warn("GeneralException: {} - {}", errorCode.getMessage(), e.getMessage());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

로그 메시지 형식을 개선하면 더 유용할 것 같습니다. 현재 형식은 BusinessException(BaseErrorCode) 생성자를 사용할 때 메시지가 중복으로 로깅될 수 있습니다. (GeneralException: <msg> - <msg>)

e.getMessage()BusinessException(String message, BaseErrorCode errorCode) 생성자에서 errorCode.getMessage()를 포함하도록 구성되어 있으므로, 다음과 같이 변경하면 중복을 피하고 에러 코드를 명시적으로 포함하여 디버깅에 더 도움이 될 것입니다.

log.warn("GeneralException: {} (code: {})", e.getMessage(), errorCode.getCode());

이렇게 하면 다음과 같이 로깅됩니다.

  • new BusinessException(errorCode) 사용 시: GeneralException: <메시지> (code: <에러코드>)
  • new BusinessException(detail, errorCode) 사용 시: GeneralException: <메시지><상세정보> (code: <에러코드>)
Suggested change
log.warn("GeneralException: {} - {}", errorCode.getMessage(), e.getMessage());
log.warn("GeneralException: {} (code: {})", e.getMessage(), errorCode.getCode());

@k3vin7 k3vin7 merged commit 0cdfe37 into main Feb 21, 2026
1 check passed
@k3vin7 k3vin7 deleted the refactor/exception branch February 21, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant