diff --git a/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt b/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt index 4437021b..29e7b38b 100644 --- a/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt +++ b/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt @@ -37,6 +37,8 @@ class JwtHandler( .body .get(MEMBER_ID_CLAIM_KEY, Number::class.java) .toLong() + } catch (_: IllegalArgumentException) { + throw AuthException(AuthErrorCode.TOKEN_NOT_FOUND) } catch (_: ExpiredJwtException) { throw AuthException(AuthErrorCode.EXPIRED_TOKEN) } catch (_: Exception) { diff --git a/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt b/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt index 91b9f376..a7ee570d 100644 --- a/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt +++ b/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt @@ -41,7 +41,7 @@ class JwtHandlerTest : FunSpec({ test("토큰이 빈 값이면 예외를 던진다.") { shouldThrow { jwtHandler.getMemberIdFromToken("") - }.errorCode shouldBe AuthErrorCode.INVALID_TOKEN + }.errorCode shouldBe AuthErrorCode.TOKEN_NOT_FOUND } test("시크릿 키가 잘못된 경우 예외를 던진다.") {