Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Webflux에서 Functional Endpoint로 코드를 작성시 ExceptionHandler를 사용 불가능한 현상 #13

Closed
BrianDYKim opened this issue Aug 16, 2022 · 1 comment · Fixed by #17

Comments

@BrianDYKim
Copy link
Collaborator

BrianDYKim commented Aug 16, 2022

문제 상황

Spring Webflux를 Controller 패턴이 아닌 Functional Endpoint로 작성 시 발생하는 단점 중 하나로는, ControllerAdvice를 통한 ExceptionHandler를 사용 불가능한데에 있다. 이를 해결해보고자 한다.

시도해보았던 것

우선 이전에 Coroutines에서 제공하는 coroutineExceptionHandler를 이용해서 해결해보려고 하였다.
그러나 이걸로 해결이 안되는 이유는, 예외 처리가 발생하게되면 예외 처리의 주체는 coroutine이 아니기 때문이다. 예외 처리의 주체는 DispatcherServlet이며, 무조건 DispatcherServlet을 거쳐서 예외에 대한 response를 뱉게끔 만들 필요가 있다.

해결 방법(예정)

아래의 링크에 소개된 방법을 조금 커스터마이징하여 적용하면 괜찮을듯하다.
Spring Webflux ExceptionHandler Functional Endpoints - 홍아지
Spring Boot - 스프링 리액티브!

@BrianDYKim BrianDYKim changed the title Spring Webflux에서 Functional Endpoint로 코드를 작성시 ExceptionHandler를 사용 불가능한 현상 해결 Spring Webflux에서 Functional Endpoint로 코드를 작성시 ExceptionHandler를 사용 불가능한 현상 Aug 16, 2022
@BrianDYKim
Copy link
Collaborator Author

아는 분과 토론을 해본 결과, 해당 해결 방법이 정확히 맞으며, Reactor에서 발생하는 모든 exception은 따로 구현체를 만드는게 옳다고한다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant