Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-421

@ExceptionHandler can't be override by @ControllerAdvice

    XMLWordPrintable

    Details

      Description

      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

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            kakawait Thibaud Lepretre
            Last updater:
            Spring Issues Spring Issues
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: