Opened 15 years ago
Closed 15 years ago
#12059 closed defect (bug) (worksforme)
fetch_feed($feedURL) throws an error when passed a bad feed...
Reported by: | wickedbrilliant | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9 |
Component: | Feeds | Keywords: | fetch, feed |
Focuses: | Cc: |
Description
If I call fetch_feed on a URL that is not a properly formed RSS feed, I don't generate any errors until I call a method on it, such as
$feed->get_item_quantity()
at which point it throws:
Fatal error: Call to undefined method WP_Error::get_item_quantity()
It doesn't seem to repond to:
if ($feed->error())
{
echo $feed->error();
}
returned false | returned some sort of error object. As it stands right now there is no way to catch errors. |
Try it:
$feed = fetch_feed("http://www.espn.com/blah.htm");
$feed->get_item_quantity();
Change History (1)
Note: See
TracTickets for help on using
tickets.
On failure, fetch_feed() returns a WP_Error object instead of a Simplepie error. (You can see how this works by looking at the code directly.)
Thus, you'll need to do something like this: