[wp-hackers] Why WP_Error Sucks

Brian Layman wp-hackers at thecodecave.com
Tue Jul 24 15:32:25 UTC 2012


While I won't say I hate them, I agree completely with Otto that 
"Exceptions should be exceptional". When you look at the extra load an 
exception handling adds to your program, you realize that they should be 
be avoided at almost all cost.  Unfortunately that means a lot of extra 
effort on our part to actually do things right in the first place - 
adding the if statements to look for what will cause the errors and 
building the logic to properly handle the work flow.  The problem is 
that this kind of coding is work and not fun. It's tedious.  
Additionally each time something comes through and is raised as an 
exception, that means there is more code you need to write to fix that 
exception.

I've not seen any performance tests on PHP to show the speed difference 
of if blocks vs exceptions, but I would be shocked if PHP somehow 
handled exceptions with more efficiency than any of the other languages 
I've worked in.

Brian Layman




More information about the wp-hackers mailing list