Skip to content

Commit

Permalink
Merge pull request #43 from dnd-side-project/feat/#42
Browse files Browse the repository at this point in the history
#42 회원 탈퇴 커스텀 예외 처리
  • Loading branch information
min-0 authored Sep 6, 2024
2 parents 1cbc7be + dd67864 commit ff2fa51
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.dnd.dndtravel.auth.exception;

public class AppleTokenRevokeException extends RuntimeException {
private static final String MESSAGE = "Error revoking Apple token";

public AppleTokenRevokeException(Exception e) {
super(MESSAGE, e);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dnd.dndtravel.auth.service;

import com.dnd.dndtravel.auth.exception.AppleTokenRevokeException;
import com.dnd.dndtravel.auth.service.dto.response.AppleSocialTokenInfoResponse;
import io.jsonwebtoken.JwsHeader;
import io.jsonwebtoken.Jwts;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void revoke(String accessToken) {
"access_token"
);
} catch (Exception e) {
throw new RuntimeException("Error revoking Apple token", e);
throw new AppleTokenRevokeException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.dnd.dndtravel.common;

import com.dnd.dndtravel.auth.exception.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.dnd.dndtravel.auth.exception.AppleTokenDecodingException;
import com.dnd.dndtravel.auth.exception.JwtTokenDecodingException;
import com.dnd.dndtravel.auth.exception.JwtTokenExpiredException;
import com.dnd.dndtravel.auth.exception.RefreshTokenInvalidException;
import com.dnd.dndtravel.map.exception.MemberAttractionNotFoundException;
import com.dnd.dndtravel.map.exception.MemberNotFoundException;
import com.dnd.dndtravel.map.exception.PhotoDeleteFailException;
Expand Down Expand Up @@ -63,6 +60,13 @@ public ResponseEntity<String> runtimeException(AppleTokenDecodingException e) {
.body("토큰 인증에 실패했습니다");
}

@ExceptionHandler(AppleTokenRevokeException.class)
public ResponseEntity<String> runtimeException(AppleTokenRevokeException e) {
return ResponseEntity
.status(HttpStatus.UNAUTHORIZED)
.body("토큰 인증에 실패했습니다");
}

@ExceptionHandler(JwtTokenExpiredException.class)
public ResponseEntity<String> runtimeException(JwtTokenExpiredException e) {
return ResponseEntity
Expand Down

0 comments on commit ff2fa51

Please sign in to comment.