Re: When is an Exception not an Exception?
| From: | Nathan Nobbe | Date: | Wed, 31 Dec 2008 19:55:00 +0000 |
| Subject: | Re: When is an Exception not an Exception? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-285303@lists.php.net to get a copy of this message | ||
On Wed, Dec 31, 2008 at 12:41 PM, <ceo@l-i-e.com> wrote:
>
> We have code like this:
>
> try
> {
> $details = $this->__client->getData($email); //Line 274
> }
> catch (SoapFault $sf)
> {
> //do stuff
> }
> catch (Exception $e)
> {
> //do more general stuff
> }
>
> SoapFault: No data found in C:\classes\Client.php on line 274
>
> Hello?
>
> What is the point of all this try/catch stuff, eh?
>
you dont have to use it if you dont want, in fact you could strip it out of
that code segment if you wanted to.
> I don't think we've done anything particularly fancy/tricky with the class
> hierarchy.
>
nobody said you did, but that has no bearing on the fact that the Soap
extension throws exceptions. as i said you dont have to catch them, but the
idea is they provide opportunities for your code to degrade gracefully in
the event of a problem occurring.
-nathan