Would like to ask you a best practice question where a spring-mvc controller is concerned. Please review the code below:
@Autowired
SomeService service;
@RequestMapping (...)
public @ResponseBody Response createSomething () {
try {
serviceResponse = service.doSomething();
//create a success response and return
}
catch (SomeServiceException e) {
//create an error response and return
}
}
Is the error handling to be done at the controller level normal practice? Or should the service class not be throwing exceptions like shown above. Please review and let me know.