diff --git a/src/main/java/com/depromeet/global/util/SecurityUtil.java b/src/main/java/com/depromeet/global/util/SecurityUtil.java index c109d0c52..aa4af8f13 100644 --- a/src/main/java/com/depromeet/global/util/SecurityUtil.java +++ b/src/main/java/com/depromeet/global/util/SecurityUtil.java @@ -1,5 +1,7 @@ package com.depromeet.global.util; +import com.depromeet.global.error.exception.CustomException; +import com.depromeet.global.error.exception.ErrorCode; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; @@ -9,6 +11,10 @@ public class SecurityUtil { public Long getCurrentMemberId() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - return Long.parseLong(authentication.getName()); + try { + return Long.parseLong(authentication.getName()); + } catch (Exception e) { + throw new CustomException(ErrorCode.AUTH_NOT_FOUND); + } } }