Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Non-fatal error handling with Mouse types?

by daxim (Curate)
on Oct 02, 2019 at 11:18 UTC ( [id://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

    daxim++

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found