Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Non-fatal error handling with Mouse types?

by daxim (Curate)
on Oct 02, 2019 at 11:18 UTC ( #11106947=note: print w/replies, xml ) Need Help??

in reply to Non-fatal error handling with Mouse types?

In theory it should be possible to use simple OOP to override the behaviour you do not want. However, I do not know how to get around the problem that the derived class does not export anymore.
package Mouse::Util::TypeConstraints::CarplessErrors { use Mouse; extends 'Mouse::Util::TypeConstraints'; sub throw_error :method { my ($self, $message, %args) = @_; warn $message; } } package Foo { use Mouse; use Mouse::Util::TypeConstraints::CarplessErrors; enum 'ErrorMode' => qw<carp error both>; has 'error_mode' => ( is => 'rw', isa => 'ErrorMode', default => ' +error' ); } Foo->new->error_mode('asdsdf');

Replies are listed 'Best First'.
Re^2: Non-fatal error handling with Mouse types?
by wanna_code_perl (Friar) on Oct 02, 2019 at 13:17 UTC


    This looks like a reasonable approach. I'll give it a try.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11106947]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2020-09-27 17:35 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (142 votes). Check out past polls.