feat(error): 공통 예외 처리 + 커스텀 ErrorCode 도입 - #18
Merged
Conversation
Replace UserNotFoundException, LoginFailedException, NoPermissionException, and RegisterException with CustomException + ErrorCode across throw sites (UserService, EmailService) and their test assertions (UserServiceTest, UserFacadeTest, WorkspaceFacadeTest, EmailServiceTest). Deletes the four now-unused exception classes.
…kspaceInaccessible)
…to CustomException
Register a custom AuthenticationEntryPoint (401 AUTHENTICATION_REQUIRED) and AccessDeniedHandler (403 ACCESS_DENIED) that write the same ErrorResponse JSON. Closes the gap where missing/expired-token denials (handled by Spring Security before DispatcherServlet) bypassed the @RestControllerAdvice and returned an empty, code-less body. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
백엔드가 에러를 HTTP status로만 내려주던 것을 개선해, 모든 에러 응답에 안정적인 기계 판독용
code를 추가합니다.ErrorCodeenum (32개 = code + HTTP status + 기본 메시지 단일 소스). 비즈니스 예외 30개 + 인증 실패 2개(AUTHENTICATION_REQUIRED,ACCESS_DENIED)CustomException(errorCode)통합, 클래스 전부 삭제GlobalExceptionHandler(@RestControllerAdvice,ResponseEntityExceptionHandler상속): 커스텀 /@Valid·ConstraintViolation(필드errors[]) / 프레임워크 예외(status 보존) / fallback 500HandlerExceptionResolver위임(401 유지). 추가로 Security 계층 인증/인가 실패도AuthenticationEntryPoint/AccessDeniedHandler로 code를 실어줌(advice 우회 경로 커버)응답 스키마 (순수 상위집합 · 하위호환)
{ code, message, status, path, timestamp, errors[] }— 모든 예외의 HTTP status 그대로 보존, 기존message/status유지,code/errors만 추가.보안
@Masked필드(비밀번호) raw 값 redaction → 응답/로그 유출 방지Test plan
./gradlew clean build(main 베이스) — 전체 테스트 그린code/errors확인 (DB/Redis 필요)AUTHENTICATION_REQUIRED(401) / 권한 부족 →ACCESS_DENIED(403) / 삭제 사용자 →INVALID_JWT확인연계
code를 미러링해 소비. 새 code 2개(AUTHENTICATION_REQUIRED·ACCESS_DENIED)는 프론트 미러에도 추가 필요 → 백엔드 배포 순서 조율.🤖 Generated with Claude Code