Skip to content

Commit

Permalink
refactor: UserDetail이 없을 때 예외 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
hyxklee committed Feb 5, 2025
1 parent cffb1be commit 8e3be88
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum ErrorMessage {
MEMBER_NOT_FOUND("회원을 찾을 수 없습니다."),
DUPLICATED_EMAIL("이미 가입된 이메일이에요!"),
EMAIL_FROM_INVALID("가천대학교 이메일이 아니에요!"),
MEMBER_ID_NOT_FOUND("토큰에서 회원 id를 찾을 수 없습니다."),

// Blacklist
BLACKLIST_ALREADY_EXISTS("이미 등록된 블랙리스트입니다."),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.gachtaxi.domain.members.exception;

import com.gachtaxi.global.common.exception.BaseException;

import static com.gachtaxi.domain.members.exception.ErrorMessage.*;
import static org.springframework.http.HttpStatus.NOT_FOUND;

public class MemberIdNotFoundException extends BaseException {
public MemberIdNotFoundException() {
super(NOT_FOUND, MEMBER_ID_NOT_FOUND.getMessage());
}

public static void throwException() {
throw new MemberIdNotFoundException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : id")
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? T(com.gachtaxi.domain.members.exception.MemberIdNotFoundException).throwException() : id")
public @interface CurrentMemberId {
/*
* AuthenticationPrincipal의 id 필드를 반환
Expand Down

0 comments on commit 8e3be88

Please sign in to comment.