Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : CustomExceptionHandlerFilter를 통한 예외처리 #38

Merged
merged 8 commits into from
Jan 2, 2024

Conversation

kkangh00n
Copy link
Collaborator

closed #36

⛏ 작업 상세 내용

  • ErrorCode 추가
  • JWT 필터 내에서 발생하는 예외에 대한 처리 필터 구현
  • 전체 코드 컨벤션 포매팅 적용

📝 작업 요약

  • ErrorCode & ErrorMessage 문구
  • 예외 처리 후 응답

☑️ 중점적으로 리뷰 할 부분

  • ExceptionHandler와 같은 형식의 응답을 하게하였습니다
  • 전체적인 코드 컨벤션을 적용하였기에, 커밋별로 보시는걸 추천합니다!

@kkangh00n kkangh00n self-assigned this Jan 2, 2024
@kkangh00n kkangh00n linked an issue Jan 2, 2024 that may be closed by this pull request
1 task
Copy link

github-actions bot commented Jan 2, 2024

Test Results

 9 files  +1   9 suites  +1   5s ⏱️ ±0s
15 tests +3  15 ✅ +3  0 💤 ±0  0 ❌ ±0 
16 runs  +3  16 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit 5ed28d1. ± Comparison against base commit cd377ef.

♻️ This comment has been updated with latest results.

@kkangh00n kkangh00n changed the title feat : feat : CustomExceptionHandlerFilter를 통한 예외처리 Jan 2, 2024
Comment on lines 37 to 40
private String toJson(ErrorResponse response) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(response);
}
Copy link
Member

Choose a reason for hiding this comment

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

저는 통합테스트 할 때 싱글톤 관련하여 리뷰를 받아서 ObjectMapper를 매 생성마다 만들지 않고 하나 만들어 놓고 그것을 계속 사용하도록 하였는데 통일하면 좋지 않을까요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ObjectMapper 객체를 호출할 때마다 생성하는 것이 아닌, 메서드 블럭 외부에서 생성시켜놓으면 좋겠다로 이해했는데 맞을까요?.?

Copy link
Member

Choose a reason for hiding this comment

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

맞습니다! 어떻게 생각하시나요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 맞는거 같아서 수정하였습니다~!~! ㅎㅎ


@Getter
@RequiredArgsConstructor
public enum ErrorCode {
NOT_EXIST_MEMBER("존재하지 않는 회원입니다."),
NOT_FOUND_REFRESH_TOKEN("알 수 없는 RefreshToken입니다."),
TOKEN_EXPIRES("토큰이 만료되었습니다. 다시 로그인 해 주세요."),
Copy link
Member

Choose a reason for hiding this comment

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

ACCESS_TOKEN_EXPIRED가 더 적절한 네이밍 같아요!
그리고 Access Token이 일치하지 않을 때도 TOKEN_EXPIRES로 나가는지 궁금합니다!

Copy link
Collaborator Author

@kkangh00n kkangh00n Jan 2, 2024

Choose a reason for hiding this comment

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

흐름을 잠시 설명해드리자면

  1. access token가 유효하지 않다면, refresh token을 확인하고
  2. refresh token도 유효하지 않다면, TOKEN_EXPIRES 메시지와 함께 출력합니다!

해당 ErrorCode는 전체 토큰이 유효하지 않을 때 사용되기에, access 키워드를 뺐습니다..!


@Getter
@RequiredArgsConstructor
public enum ErrorCode {
NOT_EXIST_MEMBER("존재하지 않는 회원입니다."),
NOT_FOUND_REFRESH_TOKEN("알 수 없는 RefreshToken입니다."),
Copy link
Member

Choose a reason for hiding this comment

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

알 수 없는 보다 유효하지 않은 이나 존재하지 않는 으로 하는게 더 직관적이지 않나 생각이 들었습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오 좋습니다! 키워드 수정하겠습니다 ㅎㅎ

@kkangh00n kkangh00n merged commit 561e7b8 into dev Jan 2, 2024
3 checks passed
@dlswns2480 dlswns2480 deleted the feat/#36 branch January 2, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature : Member JWT 접근에서의 예외 처리
3 participants