Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Non-fatal error handling with Mouse types?

by wanna_code_perl (Friar)
on Oct 02, 2019 at 09:20 UTC ( #11106943=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Previous (manual OO) code:
    sub error_mode {                                                      
    +          
        my ($s, $mode) = @_;                                              
    +          
    ...
                                                                          
    +          
        $s->{error_mode};                                                 
    +          
    }
    
  2. or download this
    # Converted to Mouse:
    enum 'ErrorMode' => qw<carp error both>;
    has 'error_mode' => ( is => 'rw', isa => 'ErrorMode', default => 'erro
    +r' );
    
  3. or download this
    Attribute (error_mode) does not pass the type constraint because: Vali
    +dation failed for 'ErrorMode' with value  at /usr/local/lib/x86_64-li
    +nux-gnu/perl/5.26.1/Mouse/Util.pm line 395.
            Mouse::Util::throw_error(Mouse::Meta::Attribute=HASH(0x56165c0
    +b5528), "Attribute (error_mode) does not pass the type constraint bec
    +a"..., "data", "", "depth", -1) called at ./t/05-errors.t line 16
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11106943]
Approved by marto
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2021-01-25 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?