Skip to content

Commit

Permalink
#18 [Update] 코드 리팩토링
Browse files Browse the repository at this point in the history
EntryPoint 예외 처리 리팩토링
  • Loading branch information
Anna-Jin committed Jul 18, 2022
1 parent 9b5d97c commit 04fb001
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 04fb001

Please sign in to comment.