title: How to handle Spring data exceptions in the repository layer
body: <p>I am writing a REST application using Spring. It is divided into 3 layers, controller, service and repository.</p>
  
  <p>The repository layer are using Spring data and MongoDb. The exceptions from MongoDb are translated to Spring Data exceptions.</p>
  
  <p>Using the @ExceptionHandler annotation I tried to catch those exceptions in the repository layer. This did not work. The only way to catch the exception with @ExceptionHandler is to put the code in the controller layer.</p>
  
  <p>Is there a way for me to catch and handle the exceptions in the repository layer,, without using try/catch blocks.</p>