From 04fb001c0d0c802c2ccc078b6668a96311043749 Mon Sep 17 00:00:00 2001 From: Anna-Jin Date: Tue, 19 Jul 2022 03:50:09 +0900 Subject: [PATCH] =?UTF-8?q?#18=20[Update]=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EntryPoint 예외 처리 리팩토링 --- .../login/jwt/exception/RestAuthenticationEntryPoint.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/mpnp/baechelin/login/jwt/exception/RestAuthenticationEntryPoint.java b/src/main/java/com/mpnp/baechelin/login/jwt/exception/RestAuthenticationEntryPoint.java index d96364c..8bc4e72 100644 --- a/src/main/java/com/mpnp/baechelin/login/jwt/exception/RestAuthenticationEntryPoint.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/exception/RestAuthenticationEntryPoint.java @@ -9,6 +9,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.time.LocalDate; +import java.time.LocalDateTime; // 인증되지 않은 유저가 요청을 했을 때 동작하는 클래스 @Slf4j @@ -47,8 +49,11 @@ private void setResponse(HttpServletResponse response, ErrorCode errorCode) thro response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); JsonObject responseJson = new JsonObject(); - responseJson.addProperty("message", errorCode.getMessage()); + responseJson.addProperty("timestamp", String.valueOf(LocalDateTime.now())); + responseJson.addProperty("status", errorCode.getStatus()); responseJson.addProperty("code", errorCode.getCode()); + responseJson.addProperty("error", errorCode.name()); + responseJson.addProperty("message", errorCode.getMessage()); response.getWriter().print(responseJson); }