diff --git a/src/main/java/com/xit/core/exception/handling/CustomErrorAttributes.java b/src/main/java/com/xit/core/exception/handling/CustomErrorAttributes.java index a243e72..ef5628d 100644 --- a/src/main/java/com/xit/core/exception/handling/CustomErrorAttributes.java +++ b/src/main/java/com/xit/core/exception/handling/CustomErrorAttributes.java @@ -1,5 +1,7 @@ package com.xit.core.exception.handling; +import com.xit.core.constant.ErrorCode; +import com.xit.core.exception.CustomBaseException; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.servlet.error.DefaultErrorAttributes; @@ -32,11 +34,21 @@ public class CustomErrorAttributes extends DefaultErrorAttributes { Map result = super.getErrorAttributes(webRequest, options); //result.remove("timestamp"); //result.put("trace", "AAAAAAAAAAAAAAAAAAAAAAA"); - log.error("================================================================================="); + + final Throwable error = super.getError(webRequest); + if(error instanceof CustomBaseException){ + ErrorCode errorCode = ((CustomBaseException) error).getErrorCode(); + result.put("status", errorCode.getHttpStatus()); + result.put("code", errorCode.getHttpStatus().toString()); + result.put("message", errorCode.getMessage()); + } + + log.error("====================== Exception handler 에서 catch하지 못한 에러 :: CustomErrorAttributes 에서 처리 =================================="); log.error("========================== 처리되지 않은 에러 발생 =================================="); log.error("{}", result); log.error("========================== 반드시 처리해 주세요 ====================================="); log.error("=================================================================================="); + return result; //return super.getErrorAttributes(webRequest, options);