php symfony exception handling/error handling

Working on a symfony application that uses nusoap (is this the best method for integrating soap work with php/symfony?) for taking credit card payments.I've simplified an example of my code below.What I'm struggling with is the best way to handle exceptions. The example below only has 1 custom exception (where should my custom exceptions reside within the directory structure of symfony? (lib/exception?)) But what happens when there are several different types of exceptions that handle a specific error? It's not very elegant to have a try/catch block with 20 odd exceptions.I'm also not sure of where I should be throwing and catching. I need to set some user flashes to alert the user of any problems, so I figure the catching should be done in the actions controller rather than within the class that handles the soap call.Could anyone please advise where I might be going wrong?I hate messy code/solutions and want to stick to the DRY principle as much as possible. I think I might also be missing some built in symfony functionality that might help with this but whenever I search I usually find examples that are for symfony 1.2, I'm using 1.4.Some examples would be great, thanks.lib/soap_payment.class.php\[code\]class SoapPayment{ public function charge() { /*assume options are setup correctly for sake of example*/ try { $this->call(); } catch (SoapPaymentClientFaultException $e) { /* should this be caught here? */ } } private function call() { $this->client->call($this->options); if ($this->client->hasFault()) { throw new SoapPaymentClientFaultException(); } }}\[/code\]apps/frontend/payment/actions/actions.class.php\[code\]class paymentActions extends sfActions{ public function executeCreate(sfWebRequest $request) { /* check form is valid etc */ $soap_payment = new SoapPayment(); try { $soap_payment->charge(); } catch (SoapPaymentClientFaultException $e) { /* or throw/catch here? */ $this->getUser()->setFlash('error', ...); $this->getLogger()->err(...); } /* save form regardless, will set a flag to check if successful or not in try/catch block */ }}\[/code\]
 
Back
Top