[wp-hackers] Error handling in WordPress

Jeremy Clarke jer at simianuprising.com
Mon Feb 15 20:29:48 UTC 2010

On Mon, Feb 15, 2010 at 3:03 PM, Vinicius Massuchetto
<viniciusandre at gmail.com> wrote:
> That looks ok, but I was trying to find a way to send every PHP +
> Wordpress errors by e-mail without showing the message to users.

I don't think this is supported in any serious way by WP. I've been
looking at the WP_Error class to assess its inclusion in my Settings
API patch and it doesn't seem to be used in the way I'd expect. There
is no global $errors object or anything like that.

All the uses I have looked at of the class are used mostly to check
the return of something to see if is_wp_error(), then maybe show the
error text if it is. The resulting object is usually destroyed though,
so there is no overall record of errors that have occured that you
could pull out and use for something else.

If you want an error displayed or emailed you'll have to harness it
yourself somehow. There is also no action or filter in the wp_error()
method, so you can't automatically know when the class is being used.
As for PHP errors the solution is probably to do something with your
server logs rather than inside WP.

Jeremy Clarke
Code and Design | globalvoicesonline.org

More information about the wp-hackers mailing list