[PHP] When is an Exception not an Exception?

2008-12-31 Thread ceo

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?



I don't think we've done anything particularly fancy/tricky with the class 
hierarchy.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] When is an Exception not an Exception?

2008-12-31 Thread Nathan Nobbe
On Wed, Dec 31, 2008 at 12:41 PM, c...@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


Re: [PHP] When is an Exception not an Exception?

2008-12-31 Thread ceo

I'm afraid I wasn't clear enough.



I thought the catch block was not actually 'catching' anything, since I'm 
seeing an error message with the line of code that is causing the Fault.



Turns out, XDebug is kindly splatting out the exception even though it's being 
caught.



Which I'm sure it desirable to many folk in dev environment.



But my colleagues' habit of using Exceptions for non-exceptional events is 
pretty much going to drive me crazy, like it or not.



There's probably some setting for xdebug that I need to turn off to just ignore 
caught Exceptions.



Hopefully it will still blow up for un-caught Exceptions...



Sorry for the noise. Now that I know what is happening, I'm feeling silly for 
asking.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] When is an Exception not an Exception?

2008-12-31 Thread phphelp -- kbk


On Dec 31, 2008, at 2:12 PM, c...@l-i-e.com wrote:

Sorry for the noise. Now that I know what is happening, I'm feeling  
silly for asking.


For me, hitting the the Send button often suddenly opens my eyes.  
Too bad there is no un-Send button.


Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] When is an Exception not an Exception?

2008-12-31 Thread Nathan Nobbe
On Wed, Dec 31, 2008 at 1:12 PM, c...@l-i-e.com wrote:


 I'm afraid I wasn't clear enough.

 I thought the catch block was not actually 'catching' anything, since I'm
 seeing an error message with the line of code that is causing the Fault.


oic.  yeah xdebug will do things like that, you may want to experiment w/
the xdebug settings in php.ini; if you cant get it cleared up that way, you
may just have to disable it to test this piece of code.

you might also look at which settings you can toggle via .htaccess.  what im
getting at is see if you can have an instance of the site w/ your settings
(possibly disable xdebug) and other instances for your colleagues where they
can enable it if they like.

Turns out, XDebug is kindly splatting out the exception even though it's
 being caught.

 Sorry for the noise. Now that I know what is happening, I'm feeling silly
 for asking.


i wouldnt worry about it; i dont think theres a spot in the xdebug docs
where they discuss how it can screw up some things you might want to leave
alone :D

-nathan