Skip to content

Support controller-specific exception handlers using @UseExceptionHandler or equivalent #35115

Closed as not planned
@karthikMNK

Description

@karthikMNK

Background

In many real-world REST APIs, developers want to handle exceptions differently per controller (e.g., user-facing vs. admin APIs). While @ControllerAdvice is powerful, it is global or package-scoped, which can lead to tight coupling and handler bloat.

Proposed Feature

Introduce a simple way to annotate a controller with a custom exception handler delegate, like:

@UseExceptionHandler(UserExceptionHandler.class)
@RestController
@RequestMapping("/users")
public class UserController {
   ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions