Skip to content

@ExceptionHandler can't be override by @ControllerAdvice [DATAREST-421] #801

@spring-projects-issues

Description

@spring-projects-issues

Thibaud Lepretre opened DATAREST-421 and commented

AbstractRepositoryRestController defines a number of @ExceptionHandler however like clearly explain here http://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc:

@ExceptionHandler methods on the Controller are always selected before those on any @ControllerAdvice instance

So as user I can't override the Spring DATA REST behavior without reimplement an HandlerExceptionResolver in order to inverse order choice between @ControllerAdvice and @ExceptionHandler methods

By switching the @ExceptionHandler methods to an instance of @ControllerAdvice user can override behavior by adding another @ControllerAdvice with better @Order inside applicationContext.

But we should be keep in mind this issue https://jira.spring.io/browse/SPR-11570. I don't know if the previous mechanism can works without the shared @ControllerAdvice, but I will try it as soon as possible.

If accepted I can send a pull request. I have already forked a working repository with @ControllerAdvice


Affects: 2.2 GA (Evans)

Referenced from: pull request #155

1 votes, 3 watchers

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions