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

ExceptionHandler in the controller is not displayed when the controller is AOP Proxy class. #2098

Closed
uc4w6c opened this issue Mar 1, 2023 · 0 comments · Fixed by #2099
Closed
Labels
enhancement New feature or request

Comments

@uc4w6c
Copy link
Collaborator

uc4w6c commented Mar 1, 2023

Describe the bug
If i add the Validated annotation etc. to the controller, it will become an AOP Proxy class, but the response returned by ExceptionHandler will not be displayed.

To Reproduce
GET /exception

@RestController
@RequestMapping("exception")
@Validated
public class ExceptionController {
  @GetMapping
  public String index() {
    throw new ExampleException();
  }

  @ExceptionHandler(ExampleException.class)
  @ResponseStatus(HttpStatus.BAD_REQUEST)
  @ApiResponse(responseCode = "400", description = "bad request")
  public String customControllerException() {
    return "exception1";
  }
}

Expected behavior

Actual

		"/exception": {
			"get": {
                                 ...
				"responses": {
					"200": {
                                          ...
					},
					"400": {
                                          ...
					}
				}
			}
		}

Expected:

		"/exception": {
			"get": {
                                 ...
				"responses": {
					"200": {
                                          ...
					}
				}
			}
		}
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
Development

Successfully merging a pull request may close this issue.

2 participants