is_wp_error() and handling errors
Im trying to build a function which grabs the feedburner "readers" using wp_remote_get()
. I noticed that it frequently returned a value of 0
.
I assumed at first that it was a WordPress error (handled by is_wp_error()
) or a flaw with wp_remote_get()
. Wrong of-course..
Feedburner just kept crashing, so I used a second transient to store a result (never 0
) with an expiration of 7 days. The part which i cant get my head around is handling errors with is_wp_error()
. I need to force an error so i can handle it properly, before I put it up on production.
Heres an illustration:
$result = wp_remote_get( 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . urlencode($username) );
if ( is_wp_error($result) )
return false;
Whats the best way to force an error? Should i use new WP_error()
?
Topic transient errors customization Wordpress
Category Web