Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Error::Simple or eval{} use to capture &Carp::croak

by SFLEX (Chaplain)
on Sep 04, 2009 at 10:44 UTC ( [id://793432]=note: print w/replies, xml ) Need Help??


in reply to Error::Simple or eval{} use to capture &Carp::croak

croak - die of errors (from perspective of caller)
croak is handled using eval{} and error is found by $@.
I have no idea what you mean by "Error objects" but to give you a better idea of how Carp works, take a look at the source.

What did the Pro-Perl programmer say to the Perl noob?
You owe me some hair.

Replies are listed 'Best First'.
Re^2: Error::Simple or eval{} use to capture &Carp::croak
by Anonymous Monk on Sep 04, 2009 at 11:50 UTC

    Written earlier, emphasis added ...

    ... Error::Simple subclasses (Error objects henceforth) ...

    ... as in ...

    # In ModErr.pm ... package ModErr; use base 'Error::Simple'; 1; # Elsewhere ... use ModErr qw[ :try ]; try { 1 == int( rand(2) ) ? call_me() : wont_you_call() ; } catch ModErr with { my ( $err ) = @_; my $text = $err->text; throw ModErr "No call back." unless $text =~ /your call/i; }; print "Everything is ok after all!\n"; sub call_me { throw ModErr "Here is your call!"; } sub wont_you_call { throw ModErr 'please?'; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-06-22 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.