Skip to content

Support for @ExceptionHandler inside @RestController only works if a @RestControllerAdvice class is present #1498

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

Closed
SimonAlthoff opened this issue Feb 8, 2022 · 1 comment · Fixed by #1500
Labels
enhancement New feature or request

Comments

@SimonAlthoff
Copy link

Describe the bug
The @ExceptionHandler methods inside a @RestController are picked up correctly if and only if there is at least one class present which is annotated with @RestControllerAdvice. This class might be empty, though.

To Reproduce
I created a fork of the master branch and added a new test app182 which is a copy of the test app124.
Except that both @exceptionhandlers are contained in the @RestController and the @RestControllerAdvice class was removed.

SimonAlthoff@8db9112

Expected behavior
@ExceptionHandler within a @RestController are picked up even when no @RestControllerAdvice class exists.

Additional context
The original feature was implemented in ticket #748

@eshishkin
Copy link
Contributor

I have created a simple PR for fixing this issue - #1500
Suppose, it can help

@bnasslahsen bnasslahsen added the enhancement New feature or request label Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants