alexdebril / rss-atom-bundle

RSS and Atom Bundle for Symfony
MIT License
139 stars 49 forks source link

Catching exceptions and error handling #48

Closed benr77 closed 7 years ago

benr77 commented 10 years ago

What is the best way to catch errors etc? I'm using Symfony2.

When I try and fetch a non-existent feed I get

Warning: SimpleXMLElement::__construct(): Entity: line 11: parser error : xmlParseEntityRef: no name in /home/chaletops/dev/vendor/debril/rss-atom-bundle/Debril/RssAtomBundle/Protocol/FeedReader.php line 21

Thanks

alexdebril commented 10 years ago

Hello,

Which version are you using ? I don't get how this error can occur with the current code.

benr77 commented 10 years ago

I'm using version 1.4.0.

alexdebril commented 10 years ago

OK, now I get it.

It's line 212 not 21 :-)

The fact that FeedReader tries to create a SimpleXmlElement with a non-existent feed is a bug. Can you give the feed's URL please ? I'll give it a try.

benr77 commented 10 years ago

Yes, exactly. There's no error checking on the SimpleXmlElement statement. I also think that there is a very specific way of catching SimpleXml errors - the PHP web site has details.

Anyway, all I did was disable my network connection and do some development offline - so presumably you can reproduce by specifying a feed with zero length content (i.e. a blank file) or perhaps simply a non-existent URL. Of course both scenarios will need to be handled.

Thanks

benr77 commented 10 years ago

Here is the info about suppressing SimpleXML errors and handling them

http://php.net/manual/en/simplexml.examples-errors.php

alexdebril commented 7 years ago

This issue is no longer accurate, I close it