DATAREST-1143 - Prefer ResourceNotFoundException over ResponseEntity.notFound().

This is to allow users to plug in custom exception handling to control these situations.

Original pull request: #284.
This commit is contained in:
Jeroen Reijn
2019-03-05 15:45:42 +01:00
committed by Oliver Drotbohm
parent 017b69c4e1
commit 6d0acfd997
2 changed files with 80 additions and 1 deletions

View File

@@ -73,6 +73,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author Oliver Gierke
* @author Greg Turnquist
* @author Jeremy Rickard
* @author Jeroen Reijn
*/
@RepositoryRestController
class RepositoryEntityController extends AbstractRepositoryRestController implements ApplicationEventPublisherAware {
@@ -334,7 +335,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem
return resourceStatus.getStatusAndHeaders(headers, it, entity).toResponseEntity(//
() -> assembler.toFullResource(it));
}).orElseGet(() -> new ResponseEntity<EntityModel<?>>(HttpStatus.NOT_FOUND));
}).orElseThrow(() -> new ResourceNotFoundException());
}
/**