moose/Moo — pull request #7 by schwern (2014-07-31 20:01:30+00:00)
Title: Switch from a DIE handler to an eval for munging coercion and isa errors.

For https://rt.cpan.org/Ticket/Display.html?id=97653

The global nature of DIE handlers, even when localized, will always be
problematic. If a default contains a chain of method calls (such as a
default which creates another object) it may go through several eval
blocks, any of which could die. The DIE handler is hard pressed to
know which is the final error and which is an intermediate.

The need to pass through exception objects unchanged just makes this
even harder.

If the code installs its own DIE handler, the whole thing goes off
the rails.

OTOH eval blocks stack naturally.

The messy bit is writing the exception handler such that it can both
catch the exception and return the value. I'm not convinced I
did it the best way. It's probably faster because local is slow.

Also...
* The tests which directly referenced $CurrentAttribute are glass box and
now make no sense.
* Any user applied DIE handlers will now trip when accessors are called.
Such is the nature of DIE handlers.