I've implemented this in a branch:
https://github.com/moose/Moo/pull/11
As you can see from the tests, the global $SIG{__DIE__} handler still
gets called, but only once, with the final, wrapped exception.
"dzagashev@gmail.com via RT" <bug-Moo@rt.cpan.org> writes:
Show quoted text> Queue: Moo
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=99733 >
>
> Global handler can, for example, log error message and exit process.
> And in current case global handler receive die message without att into.
> Localizing __DIE__ is more versatile approach, and guarantee, that attr
> info will be added in any case.
>
> On 23.10.2014 13:06, (Dagfinn Ilmari Mannsåker) via RT wrote:
>> <URL:
https://rt.cpan.org/Ticket/Display.html?id=99733 >
>>
>> Seeing as we always rethrow the error (thus triggering any $SIG{__DIE__}
>> handler then), this makes sense.
>>
>> "dzagashev@gmail.com via RT" <bug-Moo@rt.cpan.org> writes:
>>
>>> Queue: Moo
>>> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=99733 >
>>>
>>> I check $^S in my die handler, but this is not the case.
>>>
>>> The problem is that if global die handler used - code in your eval
>>> (after isa call) never will be executed and has no chance to prepend
>>> attribute information to error message.
>>>
>>> Using of:
>>>
>>> local $SIG{__DIE__} = undef;
>>>
>>> at the beginning of eval will solve the problem and don't affect the
>>> overall workflow.
>>>
>>> On 23.10.2014 3:13, Karen Etheridge via RT wrote:
>>>> <URL:
https://rt.cpan.org/Ticket/Display.html?id=99733 >
>>>>
>>>> On Wed, Oct 22, 2014 at 07:13:12PM -0400, dzagashev@gmail.com via RT wrote:
>>>>> Queue: Moo
>>>>> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=99733 >
>>>>>
>>>>> It will be useful if Moo localize $SIG{__DIE__} in
>>>>> Method::Generate::Accessor::_wrap_attr_exception.
>>>>>
>>>>> This will guarantee, that prefix will be added to error message in any case.
>>>> Moo doesn't use a __DIE__ handler -- it uses an eval to catch and modify
>>>> the exception before passing it upwards. If you are seeing these
>>>> exceptions unmodified, that suggests your handler is not checking $^S,
>>>> which is a problem in your code. See 'perldoc -f die' and 'perldoc
>>>> perlvar'.
>>>>
>>>>
>>>
>>>
>>>
>
>
>
>
--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law