스프링에서 예외 처리 하는 법

https://mangkyu.tistory.com/204

BasicErrorController를 통한 기본적인 에러 발생 흐름

WAS(톰캣) -> 필터 -> 서블릿(디스패처 서블릿) -> 인터셉터 -> 컨트롤러
-> 컨트롤러(예외발생) -> 인터셉터 -> 서블릿(디스패처 서블릿) -> 필터 -> WAS(톰캣)
-> WAS(톰캣) -> 필터 -> 서블릿(디스패처 서블릿) -> 인터셉터 -> 컨트롤러(BasicErrorController)

BasicErrorController 에러 속성

{
    "timestamp": "2021-12-31T03:35:44.675+00:00",
    "status": 500,
    "error": "Internal Server Error",
    "trace": "java.util.NoSuchElementException: No value present ...",
    "message": "No value present",
    "path": "/product/5000"
}
server.error.include-message: always
server.error.include-binding-errors: always
server.error.include-stacktrace: always // 운영 환경에서는 X
server.error.include-exception: false

예외 처리 방법

HandlerExceptionResolver