cormanaz has asked for the wisdom of the Perl Monks concerning the following question:

Bros,

I am reading RSS feeds with XML::FeedPP. It's been working fine for quite some time, but today I got an error on the cron job Invalid string: [\x6A\x74\x61\x62\x6C\x65\x73\x65\x73\x73\x69\x6F\x6E::\x73\x74\x6F\x72\x65 \x66\x61\x69\x6C\x65\x64] before <br /> at /home/perl/usr/lib/perl5/site_perl/5.8.8/XML/FeedPP.pm line 478

Line 478 is where it's parsing the feed, so obviously, there is a squirrely entry in one of the feeds I'm reading, which I'm tracking down.

But I was surprised to get this error in the first place because I'm invoking the feed inside an eval to guard against such an event, i.e. eval { $feed = XML::FeedPP->new( $feedurl ) }; Will this not trap errors that occur inside the module? If not is there some other way to do that? I don't want my reader to crash every time someone inserts a non-standard element in a feed.

TIA....Steve

Replies are listed 'Best First'.
Re: XML::FeedPP how to trap error
by saberworks (Curate) on Aug 13, 2008 at 15:43 UTC
    The eval will trap any die/exit statements or errors, but it won't stop code from emitting warnings or error messages. Did the cron run the rest of the way successfully and that is only warning message, or did it actually die and not finish? What version of FeedPP are you using?
      God question, I don't know if it completed or not; insufficient logging to tell. I will set that up in case I get the error again. I'm using ver 0.35.