Skip to content

Commit

Permalink
remove: 사용하지 않는 예외 코드 삭제
Browse files Browse the repository at this point in the history
사용하지 않는 예외코드 삭제
  • Loading branch information
yunjunghun0116 committed Aug 1, 2024
1 parent d7db93a commit a8a4281
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 23 deletions.
14 changes: 0 additions & 14 deletions src/main/java/gift/exception/GlobalExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package gift.exception;

import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mapping.PropertyReferenceException;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
Expand All @@ -12,8 +10,6 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.net.URI;

@RestControllerAdvice
public class GlobalExceptionHandler {

Expand All @@ -24,8 +20,6 @@ public class GlobalExceptionHandler {
private static final String INVALID_LOGIN_INFO_MESSAGE = "로그인 정보가 유효하지 않습니다.";
private static final String INVALID_PAGE_REQUEST_MESSAGE = "요청에 담긴 페이지 정보가 유효하지 않습니다.";
private static final String EXPIRED_JWT_MESSAGE = "인증 정보가 만료되었습니다.";
@Value("${kakao.redirect-token-uri}")
private String redirectTokenUri;

@ExceptionHandler(value = NotFoundElementException.class)
public ResponseEntity<ExceptionResponse> notFoundElementExceptionHandling() {
Expand Down Expand Up @@ -62,14 +56,6 @@ public ResponseEntity<ExceptionResponse> expiredJwtExceptionHandling() {
return getExceptionResponse(EXPIRED_JWT_MESSAGE, HttpStatus.UNAUTHORIZED);
}

@ExceptionHandler(value = InvalidKakaoTokenException.class)
public ResponseEntity<Void> invalidKakaoTokenExceptionHandling() {
var headers = new HttpHeaders();
String redirectLocation = redirectTokenUri;
headers.setLocation(URI.create(redirectLocation));
return new ResponseEntity<>(headers, HttpStatus.MOVED_PERMANENTLY);
}

@ExceptionHandler(value = BadRequestException.class)
public ResponseEntity<ExceptionResponse> badRequestExceptionHandling(BadRequestException exception) {
return getExceptionResponse(exception.getMessage(), HttpStatus.BAD_REQUEST);
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/gift/exception/InvalidKakaoTokenException.java

This file was deleted.

3 changes: 1 addition & 2 deletions src/main/java/gift/service/KakaoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import gift.dto.giftorder.GiftOrderResponse;
import gift.dto.kakao.KakaoAuthInformation;
import gift.dto.kakao.KakaoTokenResponse;
import gift.exception.InvalidKakaoTokenException;
import gift.exception.NotFoundElementException;
import gift.exception.UnauthorizedAccessException;
import gift.model.Member;
Expand Down Expand Up @@ -88,7 +87,7 @@ private OauthToken createAndSaveOauthToken(Member member, KakaoTokenResponse kak

private OauthToken updateOauthToken(Member member, KakaoTokenResponse kakaoTokenResponse) {
var kakaoToken = oauthTokenRepository.findByMemberIdAndOauthType(member.getId(), OauthType.KAKAO)
.orElseThrow(() -> new InvalidKakaoTokenException(member.getId() + "를 가진 이용자의 카카오 토큰 정보가 존재하지 않습니다."));
.orElseThrow(() -> new NotFoundElementException(member.getId() + "를 가진 이용자의 카카오 토큰 정보가 존재하지 않습니다."));
kakaoToken.updateToken(kakaoTokenResponse.accessToken(), kakaoTokenResponse.accessTokenExpiresIn(), kakaoTokenResponse.refreshToken(), kakaoTokenResponse.refreshTokenExpiresIn());
return oauthTokenRepository.save(kakaoToken);
}
Expand Down

0 comments on commit a8a4281

Please sign in to comment.