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

Unable to implement custom error handling for RepositoryEntityController#getItemResource in case of item not found

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6.7 (Ingalls SR7), 3.0 GA (Kay)
    • Fix Version/s: 3.2 M2 (Moore)
    • Component/s: None
    • Labels:
      None

      Description

      We're building a REST API based on spring-data-rest and we're trying to implement custom error response messages.

      We have our own CustomRestExceptionHandler and this seems to work all fine for almost all cases except for getting an item by ID. When fetching a non-existing entity, a 404 status is returned without a message body and no catchable exception is thrown.

      I noticed that RepositoryEntityController#getItemResource directly returns a new ResponseEntity<Resource<?>>(HttpStatus.NOT_FOUND) instead of throwing a ResourceNotFoundException like for instance the RepositoryEntityController#headForItemResource does. It would like to suggest that getItemResource returns a ResourceNotFoundException so it can be caught and/or generates an error response message.

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            jreijn Jeroen Reijn
            Last updater:
            Christoph Strobl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: