Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-08-2007, 06:46 AM
Junior Member
 
Join Date: Aug 2007
Posts: 7
Default Zend_Feed - Throw exception instead of error?

I have this code:
PHP Code:
 try {
            
$channel Zend_Feed::import($r['parentURL']);
        } catch (
Zend_Feed_Exception $e) {
            
$insertArray = array('statusParentID' => $r['parentID'], 'statusDate' => time(),'statusError' => $e->getMessage());
            
$db->insert('feed_status'$insertArray);
        } 
Instead of going in the catch { } when it fails to load the RSS it goes:
Quote:
Fatal error: Uncaught exception 'Zend_Http_Client_Adapter_Exception' with message 'Unable to Connect to tcp://www.xc-ski.de:80. Error #60: Operation timed out'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-08-2007, 09:12 AM
Junior Member
 
Join Date: Oct 2007
Posts: 2
Default

Hi Parse,

The problem seems to be that you're checking for a Zend_Feed_Exception, while the code throws a Zend_Http_Client_Adapter_Exception. That means that the latter should be subclassed from the first, or you should check for both.

Obviously, there is always the possibility to check for Zend_Exception, since every Exception inherits from that.

Regards,

Berry.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-08-2007, 09:15 AM
Junior Member
 
Join Date: Oct 2007
Posts: 2
Default

Quote:
Originally Posted by berry__ View Post
Obviously, there is always the possibility to check for Zend_Exception, since every Exception inherits from that.
To illustrate:

try {
$channel = Zend_Feed::import($r['parentURL']);
} catch (Zend_Feed_Exception $e) {
$insertArray = array('statusParentID' => $r['parentID'], 'statusDate' => time(),'statusError' => $e->getMessage());
$db->insert('feed_status', $insertArray);
} catch( Zend_Exception ) {
/** Exception is catched here, if the exception wasn't Zend_Feed_Exception or child. **/
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-08-2007, 11:34 AM
Junior Member
 
Join Date: Aug 2007
Posts: 7
Default

Thanks berry. Works like a charm.

Last edited by parse : 10-08-2007 at 11:34 AM. Reason: typo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:37 PM.