Refactor: Error 응답 변경

This commit is contained in:
김용수 2024-09-19 17:57:44 +09:00
parent ae2a55434f
commit c4091d14a3
3 changed files with 0 additions and 12 deletions

View File

@ -21,9 +21,5 @@ public class CustomAuthenticationDeniedHandler implements AccessDeniedHandler {
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
log.debug("오류 : {}", request.getAttribute("error-message"));
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
CustomException exception = new CustomException(ErrorCode.ACCESS_DENIED);
ErrorResponse errorResponse = new ErrorResponse(exception, request.getAttribute("error-message").toString());
response.setContentType("application/json;charset=utf-8");
response.getWriter().write(errorResponse.toJson());
}
}

View File

@ -21,12 +21,5 @@ public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
log.debug("인증 실패 오류 : {} ", request.getAttribute("error-message"));
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
CustomException exception = new CustomException(ErrorCode.INVALID_TOKEN);
if (request.getAttribute("error-message") == null) {
request.setAttribute("error-message", exception.getMessage());
}
ErrorResponse errorResponse = new ErrorResponse(exception, request.getAttribute("error-message").toString());
response.setContentType("application/json;charset=UTF-8");
response.getWriter().write(errorResponse.toJson());
}
}

View File

@ -49,7 +49,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
throw new JwtException("유효한 JWT 토큰이 없습니다.");
}
} catch (Exception e) {
log.debug("message: {}", e.getMessage());
request.setAttribute("error-message", e.getMessage());
}
filterChain.doFilter(request, response);