Why WP_Error Sucks

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Why WP_Error Sucks

Ryan McCue-3
Hi hackers!

I just posted a blog post regarding WP_Error, and why it (quite frankly)
sucks: http://journal.ryanmccue.info/165/why-wp_error-sucks/

I'd be interested to hear your thoughts on WP_Error and the possibility
of using exceptions as well. I'd also love to hear from anyone who has
implemented exceptions in their own plugin code.

(Bonus points if you're a core developer, especially if you're westi ;) ).

Cheers,
--
Ryan McCue
<http://ryanmccue.info/>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Otto-19
Exceptions and try/catch don't parse in PHP 4 environments, leading to
fatal parsing errors.

-Otto


On Tue, Jul 24, 2012 at 7:56 AM, Ryan McCue <[hidden email]> wrote:

> Hi hackers!
>
> I just posted a blog post regarding WP_Error, and why it (quite frankly)
> sucks: http://journal.ryanmccue.info/165/why-wp_error-sucks/
>
> I'd be interested to hear your thoughts on WP_Error and the possibility
> of using exceptions as well. I'd also love to hear from anyone who has
> implemented exceptions in their own plugin code.
>
> (Bonus points if you're a core developer, especially if you're westi ;) ).
>
> Cheers,
> --
> Ryan McCue
> <http://ryanmccue.info/>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Harry Metcalfe-4
In reply to this post by Ryan McCue-3
Did someone post some stats recently about what versions of PHP in use by WP sites?

I completely agree that exceptions would be better, but presumably, that has to wait until so few people are still on PHP4 that we can make PHP5+ a requirement.

Harry



On 24 Jul 2012, at 13:56, Ryan McCue wrote:

> Hi hackers!
>
> I just posted a blog post regarding WP_Error, and why it (quite frankly)
> sucks: http://journal.ryanmccue.info/165/why-wp_error-sucks/
>
> I'd be interested to hear your thoughts on WP_Error and the possibility
> of using exceptions as well. I'd also love to hear from anyone who has
> implemented exceptions in their own plugin code.
>
> (Bonus points if you're a core developer, especially if you're westi ;) ).
>
> Cheers,
> --
> Ryan McCue
> <http://ryanmccue.info/>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Ryan McCue-3
Harry Metcalfe wrote:
> I completely agree that exceptions would be better, but presumably, that has to wait until so few people are still on PHP4 that we can make PHP5+ a requirement.

WordPress currently requires PHP 5.1.4+, as of WP 3.2:
http://wordpress.org/news/2010/07/eol-for-php4-and-mysql4/

--
Ryan McCue
<http://ryanmccue.info/>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

William P. Davis-2
In reply to this post by Ryan McCue-3
PHP5 is required in recent versions of WordPress, so I would agree that WP_Error should use exceptions. I would urge you to submit a patch to Trac.

Will
------Original Message------
From: Harry Metcalfe
Sender: [hidden email]
To: [hidden email]
ReplyTo: [hidden email]
Subject: Re: [wp-hackers] Why WP_Error Sucks
Sent: Jul 24, 2012 9:16 AM

Did someone post some stats recently about what versions of PHP in use by WP sites?

I completely agree that exceptions would be better, but presumably, that has to wait until so few people are still on PHP4 that we can make PHP5+ a requirement.

Harry



On 24 Jul 2012, at 13:56, Ryan McCue wrote:

> Hi hackers!
>
> I just posted a blog post regarding WP_Error, and why it (quite frankly)
> sucks: http://journal.ryanmccue.info/165/why-wp_error-sucks/
>
> I'd be interested to hear your thoughts on WP_Error and the possibility
> of using exceptions as well. I'd also love to hear from anyone who has
> implemented exceptions in their own plugin code.
>
> (Bonus points if you're a core developer, especially if you're westi ;) ).
>
> Cheers,
> --
> Ryan McCue
> <http://ryanmccue.info/>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers

Sent from my BlackBerry
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Ryan McCue-3
In reply to this post by Otto-19
Otto wrote:
> Exceptions and try/catch don't parse in PHP 4 environments, leading to
> fatal parsing errors.

I replied to your comment on my post, but to reiterate here: that's only
a problem for the very few files that are loaded before WP checks for
PHP 5+. These are small enough that it doesn't really matter (and is
really no different to protected/private keywords, etc).

--
Ryan McCue
<http://ryanmccue.info/>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Ryan McCue-3
In reply to this post by William P. Davis-2
William P. Davis wrote:
> PHP5 is required in recent versions of WordPress, so I would agree that WP_Error should use exceptions. I would urge you to submit a patch to Trac.

I didn't mention it in the post, but this has been previously discussed:
http://core.trac.wordpress.org/ticket/16769

The idea of this post was to get the idea out there, see if there's any
good points against implementing it, and then to begin that process.
I'll happily contribute a patch, but at the moment, I don't see it as a
possibility.

I'd love to hear from core committers/contributors on what they'd think
about it.

--
Ryan McCue
<http://ryanmccue.info/>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Ryan WP Mailing Lists
In reply to this post by Ryan McCue-3
As a caregivers from my .net programming I use and am comfortable with the
concept of exceptions. WP_Error on the otherhand I just don't quite get. In
fact I admit I don't implement it in my plugins, not that it matters since
I have never made a pouting for public release but still.

I like the idea and honestly now that PHP supports it with version 5 why
not as it is the dare I say "correct" method of error handling.
On Jul 24, 2012 5:56 AM, "Ryan McCue" <[hidden email]> wrote:

> Hi hackers!
>
> I just posted a blog post regarding WP_Error, and why it (quite frankly)
> sucks: http://journal.ryanmccue.info/165/why-wp_error-sucks/
>
> I'd be interested to hear your thoughts on WP_Error and the possibility
> of using exceptions as well. I'd also love to hear from anyone who has
> implemented exceptions in their own plugin code.
>
> (Bonus points if you're a core developer, especially if you're westi ;) ).
>
> Cheers,
> --
> Ryan McCue
> <http://ryanmccue.info/>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Otto-19
On Tue, Jul 24, 2012 at 8:43 AM, Ryan WP Mailing Lists
<[hidden email]> wrote:
> As a caregivers from my .net programming I use and am comfortable with the
> concept of exceptions. WP_Error on the otherhand I just don't quite get. In
> fact I admit I don't implement it in my plugins, not that it matters since
> I have never made a pouting for public release but still.
>
> I like the idea and honestly now that PHP supports it with version 5 why
> not as it is the dare I say "correct" method of error handling.


Okay, I would let this go, but... argh. "Correctness" is relative.

IMO, Exceptions suck rocks. This applies to every language they're
implemented in.

The base problem I have with Exceptions is that they should be used
for error handling, but what they invariably end up being used for is
program logic.

Exceptions, when you break it down, are a way to have a return value
from a function that is outside the normal scope of what the function
returns. If a function is supposed to return an integer value, but
something happens where it needs to signal the calling code something
else, then there's two ways to handle it:
a) special return values - this is harder in a strongly typed language
where the return value must fit into an int, for example. PHP is not
such a language.
b) Exceptions, where you "throw" an error condition and expect the
calling code to wrap in a try/catch to handle that special condition.

With a, at least you can define things as such that the calling code
will have to properly handle them. With exceptions, the calling code
can optionally handle the problem or just pass the Exception up the
call stack.

What this generally means is that you have some lazy coder ignoring
the Exceptions, and then a higher level code doing try{ } catch (
Exception e ) { } to just catch them all like some demented Pokemon
cartoon.

Furthermore, Exceptions should be exceptional, meaning that they
should be errors, basically. If I call a function and it throws an
Exception, then I'm presumably expected to handle that exception case
in some manner, to resolve the error. However, if I could have done
that, then I probably should have done it to begin with, and if I was
capable of eliminating the error possibility, then I don't need to
handle the exception case anyway. Meaning that all *real* Exceptions
in the world end up going back up the call stack and just presenting
some error to the user. So when Exceptions are useful, then they're
useless. By design.

While you can attribute a lot of this to shitty programmers, I think
Exceptions themselves encourage this sort of poor and lazy coding,
honestly. They don't encourage "defensive" coding, by which I mean to
write your code so that the error conditions are handled from the
actual program logic. Instead, the existence of Exceptions and
exception handling encourages developers to simply catch "expected"
exceptions and then ignore them in order to make the compiler happy.
This leads to poor code, difficulty of debugging, and general
crappiness. Look at virtually all Java code. Most .NET code is worse,
but harder to find anybody using (bad Java is somewhat everywhere).

This comes about mostly because Exceptions intentionally break
encapsulation. In order to handle an exception properly, I need to
know something about the implementation of the code that threw the
exception to begin with. Poor object oriented design.

So yeah, I hate 'em. Especially in PHP where we're not limited to
strict typed return values. I can return an int, a string, an object,
whatever I like. As long as it's defined well, and it's easy for the
calling code to discriminate between the expected return value vs a
WP_Error object, then Exceptions don't offer me much except for that
breaking of encapsulation, which I don't see as necessarily a good
thing.

-Otto
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Harry Metcalfe-4
In reply to this post by Ryan McCue-3
Ah. That'll teach me to post without checking :)


On 24 Jul 2012, at 14:20, Ryan McCue wrote:

> Harry Metcalfe wrote:
>> I completely agree that exceptions would be better, but presumably, that has to wait until so few people are still on PHP4 that we can make PHP5+ a requirement.
>
> WordPress currently requires PHP 5.1.4+, as of WP 3.2:
> http://wordpress.org/news/2010/07/eol-for-php4-and-mysql4/
>
> --
> Ryan McCue
> <http://ryanmccue.info/>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Andrew Nacin-2
In reply to this post by Ryan McCue-3
On Tue, Jul 24, 2012 at 8:56 AM, Ryan McCue <[hidden email]> wrote:

> Hi hackers!
>
> I just posted a blog post regarding WP_Error, and why it (quite frankly)
> sucks: http://journal.ryanmccue.info/165/why-wp_error-sucks/
>
> I'd be interested to hear your thoughts on WP_Error and the possibility
> of using exceptions as well. I'd also love to hear from anyone who has
> implemented exceptions in their own plugin code.
>
> (Bonus points if you're a core developer, especially if you're westi ;) ).
>

WordPress, for better and sometimes for worse, has its own way to doing
things. WP_Error has served us well. Refactoring areas of the codebase to
use and handle exceptions just doesn't make a lot of sense right now. Not
when we strive for backwards compatibility, and not when we put users
first. As you said in your article, it wouldn't be a fun or particularly
safe conversion. It is a good rule of thumb to actually benefit from such
overhauls. I'd rather invest my time in a lot of other architectural
projects.

You also mention the idea of putting try/catch inside of the plugin API —
that would be terribly slow, and defeats the purpose of forcing exceptions
on developers. Congratulations, a plugin developer didn't code for an
exception because they knew core would catch it and issue a wp_die()
message, like that error would ever happen anyway. No thanks.

We use WP_Error for probably three distinct things:

1. As return codes. Often, WP_Error is used when the error is not
"exceptional." It enables you to pass multiple errors, and also extra data.
Using WP_Error as a return value is nice in the authentication API, for
example. It is also very helpful as a value passed to filters, to then
either be modified or checked against by plugins. The action/filter
paradigm is almost unique to WordPress, and is what defines WordPress
development in many ways. WP_Error assists with that, in a far cleaner way
than an exception would. Even with exceptions, we would still want WP_Error
as verbose return codes, because don't get me started on bitwise operators.

2. As legitimate errors where exceptions could be used, but shouldn't be.
This kind of factors into return codes. I personally do not find a failed
HTTP request to be "exceptional" that, if uncaught, should result in a
fatal error. At the very least, it certainly depends on what you're trying
to do — an API request, or maybe just something in the background.
Sometimes, you actually just don't care about the return value of
something. But hey, that's just me.

3. As legitimate errors where exceptions can and should be used, but won't
be. Exceptions can be useful in particular instances in WordPress. For
example, during plugin/theme installation and upgrade, for core updates.
We're doing a ton with the filesystem here: downloading archives, verifying
and unzipping them, creating folders, moving files, setting permissions,
etc. Some code here is ripe for exceptions — otherwise, we're forced to
check, over and over again, that our most recent result isn't a WP_Error.
Wrapping all of this in a try/catch would be nice. (I think relying on
exceptions to bubble is lazy; we'd be handling these all within that
routine.)

However, two major problems with this. One,
wp-admin/includes/update-core.php is copied over during a core update and
executed by the currently installed version. Can't throw a WP_Exception
when WP_Exception doesn't exist yet. Since you can update across multiple
major versions at once, you can never really do this well without coding
around it. So, the one place where I could see a benefit to exceptions,
couldn't truly benefit from them without needless refactoring.

The second problem is that PHP doesn't have finally blocks. This is
absurdly stupid. We'd be using try/catch when dealing with filesystem
operations, in particular upgrades. That means we need to roll back, clean
up, release locks, whatever. If WP_Error sucks because it requires slightly
more code and forces programmers to defensively consider errors, rather
than letting everything bubble up, then it sucks. But if try/catch is
supposed to make the code cleaner, then the lack of finally really blows
that argument out of the water.

I'm not saying there isn't a single use in WordPress for a WP_Exception. I
know for a fact there are some, but I also don't think there are enough
examples where an exception would be oh-just-so-much-better than error
objects to justify a paradigm change. As it is, WordPress is getting
complicated (almost too complicated) in certain areas, and it'll only serve
to hurt theme developers, designers, and many weaker plugin authors the
more "by the book" we become.

And of course, plugin authors can already use exceptions if they wanted to.
Write your own HTTP API wrapper that throws exceptions — come on, you're a
programmer, do what programmers do: make a personal, convoluted abstraction
layer. :-)

Nacin
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Michael D Adams-2
In reply to this post by Ryan McCue-3
On Tue, Jul 24, 2012 at 5:56 AM, Ryan McCue <[hidden email]> wrote:
> I'd be interested to hear your thoughts on WP_Error and the possibility
> of using exceptions as well. I'd also love to hear from anyone who has
> implemented exceptions in their own plugin code.

Joel Spolsky's opinion:
http://www.joelonsoftware.com/items/2003/10/13.html (Exceptions are
worse than GOTOs)
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Almog Baku
According to the official requirements wordpress require php5.2.4(if
you ask me it really great time to upgrade this require to 5.3/5.4 for
the new release of wordpress ver. 3.6).

So- By this argument.. I totally agree. I think exceptions will be much better.


On Tue, Jul 24, 2012 at 5:58 PM, Michael D Adams <[hidden email]> wrote:

> On Tue, Jul 24, 2012 at 5:56 AM, Ryan McCue <[hidden email]> wrote:
>> I'd be interested to hear your thoughts on WP_Error and the possibility
>> of using exceptions as well. I'd also love to hear from anyone who has
>> implemented exceptions in their own plugin code.
>
> Joel Spolsky's opinion:
> http://www.joelonsoftware.com/items/2003/10/13.html (Exceptions are
> worse than GOTOs)
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Amy Hendrix
Not likely to happen while 72% of the installed base is on 5.2

On Tue, Jul 24, 2012 at 11:10 AM, Almog Baku <[hidden email]> wrote:

> According to the official requirements wordpress require php5.2.4(if
> you ask me it really great time to upgrade this require to 5.3/5.4 for
> the new release of wordpress ver. 3.6).
>
> So- By this argument.. I totally agree. I think exceptions will be much better.
>
>
> On Tue, Jul 24, 2012 at 5:58 PM, Michael D Adams <[hidden email]> wrote:
>> On Tue, Jul 24, 2012 at 5:56 AM, Ryan McCue <[hidden email]> wrote:
>>> I'd be interested to hear your thoughts on WP_Error and the possibility
>>> of using exceptions as well. I'd also love to hear from anyone who has
>>> implemented exceptions in their own plugin code.
>>
>> Joel Spolsky's opinion:
>> http://www.joelonsoftware.com/items/2003/10/13.html (Exceptions are
>> worse than GOTOs)
>> _______________________________________________
>> wp-hackers mailing list
>> [hidden email]
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Ferenc Gergely Szilagyi
Requiring PHP5 to run doesn't means that you also must use all PHP5
features, just because they are there.

On Tue, Jul 24, 2012 at 5:12 PM, Amy Hendrix <[hidden email]> wrote:

> Not likely to happen while 72% of the installed base is on 5.2
>
> On Tue, Jul 24, 2012 at 11:10 AM, Almog Baku <[hidden email]> wrote:
>> According to the official requirements wordpress require php5.2.4(if
>> you ask me it really great time to upgrade this require to 5.3/5.4 for
>> the new release of wordpress ver. 3.6).
>>
>> So- By this argument.. I totally agree. I think exceptions will be much better.
>>
>>
>> On Tue, Jul 24, 2012 at 5:58 PM, Michael D Adams <[hidden email]> wrote:
>>> On Tue, Jul 24, 2012 at 5:56 AM, Ryan McCue <[hidden email]> wrote:
>>>> I'd be interested to hear your thoughts on WP_Error and the possibility
>>>> of using exceptions as well. I'd also love to hear from anyone who has
>>>> implemented exceptions in their own plugin code.
>>>
>>> Joel Spolsky's opinion:
>>> http://www.joelonsoftware.com/items/2003/10/13.html (Exceptions are
>>> worse than GOTOs)
>>> _______________________________________________
>>> wp-hackers mailing list
>>> [hidden email]
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> _______________________________________________
>> wp-hackers mailing list
>> [hidden email]
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Brian Layman-5
In reply to this post by Otto-19
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


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Andrew Nacin-2
On Tue, Jul 24, 2012 at 11:32 AM, Brian Layman
<[hidden email]>wrote:

> 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.


Nope, they're terribly slow in PHP too. Which is fine if they're only used
for catching critical failures ("exceptional" circumstances). That's not
the case with our WP_Error usage (as I summarized).
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Andrew Nacin-2
In reply to this post by Michael D Adams-2
On Tue, Jul 24, 2012 at 10:58 AM, Michael D Adams <[hidden email]> wrote:

> On Tue, Jul 24, 2012 at 5:56 AM, Ryan McCue <[hidden email]> wrote:
> > I'd be interested to hear your thoughts on WP_Error and the possibility
> > of using exceptions as well. I'd also love to hear from anyone who has
> > implemented exceptions in their own plugin code.
>
> Joel Spolsky's opinion:
> http://www.joelonsoftware.com/items/2003/10/13.html (Exceptions are
> worse than GOTOs)


Ah, yes, I was looking for this link. Thanks, Mike. Anything that Otto, I,
and others didn't cover, is dealt with there.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

Ryan WP Mailing Lists
In reply to this post by Brian Layman-5
I guess given my experience with .net I was tought exceptions so I really
don't know better I guess. I also don't really understand WP_Error. Does
anyone know of a good overview of it I could have a look at?
On Jul 24, 2012 8:33 AM, "Brian Layman" <[hidden email]> wrote:

> 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
>
>
> ______________________________**_________________
> wp-hackers mailing list
> [hidden email].**com <[hidden email]>
> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Why WP_Error Sucks

scribu-2
On Tue, Jul 24, 2012 at 8:30 PM, Ryan WP Mailing Lists <
[hidden email]> wrote:

> I also don't really understand WP_Error. Does
> anyone know of a good overview of it I could have a look at?
>

It's just a class. The best overview you'll find anywhere:
http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-error.php

--
http://scribu.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
12