[wp-trac] [WordPress Trac] #16769: Make WP_Error extending Exception to make it throw-able

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 8 09:30:23 UTC 2011


#16769: Make WP_Error extending Exception to make it throw-able
-------------------------+-----------------------------
 Reporter:  hakre        |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  lowest       |   Milestone:  Future Release
Component:  General      |     Version:  3.1
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+-----------------------------

Comment (by westi):

 Replying to [comment:7 filosofo]:
 > We currently have poor-man's exceptions in a number of places.  For
 example, [http://core.trac.wordpress.org/browser/trunk/wp-includes/ms-
 functions.php#L276 here] a `WP_Error` object is returned, but nothing in
 core WP does anything with that return value.  So upon error the logic
 branches, an error object is created, but nothing can be done with the
 helpful information in the way that a thrown exception could be caught.
 >

 The real bug is that nothing actually checks for the WP_Error that is
 returned.

 Switching to throwing the Error Object instead makes it harder to track
 error handling correctly in my experience.

 Ideally everywhere we could return a WP_Error we should be checking for it
 in the calling code and anywhere we don't is a bug.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16769#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list