Skip to content

Commit

Permalink
Feat: getDebate API 예외처리
Browse files Browse the repository at this point in the history
  • Loading branch information
ho0010 committed Aug 15, 2024
1 parent fd517a8 commit 2202b93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public enum BaseExceptionResponseStatus implements ResponseStatus {
INVALID_COMMENT_HEART_VALUE(6004,HttpStatus.BAD_REQUEST.value(), "댓글 좋아요 생성 요청에서 잘못된 값이 존재합니다."),
COMMENT_NOT_FOUND(6005,HttpStatus.BAD_REQUEST.value(), "해당 댓글이 존재하지 않습니다."),
KEYWORD_NOT_FOUND(6006,HttpStatus.BAD_REQUEST.value(), "해당 키워드가 존재하지 않습니다."),
INVALID_GET_DEBATE_VALUE(6007,HttpStatus.BAD_REQUEST.value(), "토론 상세 정보 요청에서 잘못된 값이 존재합니다."),



/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ public BaseResponse<Object> deleteUserVoteChoice(@Valid @RequestBody DeleteUserV
@GetMapping("/details")
public BaseResponse<GetDebateResponse> getDebate(
@RequestParam Long debateId,
@RequestHeader("Authorization") String token) {
@RequestHeader("Authorization") String token,BindingResult bindingResult) {

String jwtToken = token.substring(7);


if (bindingResult.hasErrors()) {
throw new DebateException(INVALID_GET_DEBATE_VALUE, getErrorMessages(bindingResult));
}

GetDebateResponse debateResponse = debateService.getDebate(debateId, jwtToken);

return new BaseResponse<>(debateResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public GetDebateResponse getDebate(Long debateId, String token) {
if (jwtProvider.isExpiredToken(token)) {
throw new JwtUnauthorizedTokenException(INVALID_TOKEN);
}

Long userId = jwtProvider.getUserIdFromToken(token);

Debate debate = debateRepository.findById(debateId)
Expand Down

0 comments on commit 2202b93

Please sign in to comment.