I'm wondering where I should throw, catch exception in my Zend Framework + Doctrine 2 MVC application.
Here is my design:
Database - MySQL > ORM (Doctrine2) > Service > Controller
My Service take service object in argument and return Service response object for almost all methods.
Service response returns a status, messages and the data which can be whatever you want.
My controllers consumes those services.
I'm wondering where should I throw my exception.
Example:
public function getAllMembers(ServiceObject $data)
{
// do some mapping with $data
$users = $userRepository->getAllMembers($data);
$response = new ServiceResponse('success');
$response->setData($users);
return $response;
}
Should I check for parameters in my Service, and then throw an exception which my controller can catch, or should I throw in, let's say my repository for this example, and catch in my service to allow me to return a ServiceResponse with an error status?
Any feedback about this kind of architecture?