Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Error codes vs die exceptions vs ...

by LanX (Sage)
on Jul 07, 2019 at 14:19 UTC ( #11102499=note: print w/replies, xml ) Need Help??


in reply to Re^3: Error codes vs die exceptions vs ...
in thread Error codes vs die exceptions vs ...

Sorry, I should have been clearer

> > if the class can't be handled locally.

let's say you want to catch one exception class directly but delay handling of other classes to higher scopes ...

Then you'd need to propagate the unhandled exception classes again in the first catch{...} to reach the next catch{...}

... right?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^5: Error codes vs die exceptions vs ...
by haj (Priest) on Jul 07, 2019 at 19:21 UTC
    Then you'd need to propagate the unhandled exception classes

    That's true for Try::Tiny. My first encounter with Perl's exceptions "beyond eval/die" was Error, which is much like Java in that it allows you to catch a particular error class, and passes all other errors on. TryCatch also does this, but I've never used it.

    Error has its quirks as is clearly indicated in the module's description (section "Warnings"), and TryCatch uses the spooky Devel::Declare, so getting accustomed to propagate unhandled errors is probably a good idea.

Re^5: Error codes vs die exceptions vs ...
by holli (Abbot) on Jul 07, 2019 at 14:27 UTC
    In Perl, yes. It's different for most strongly typed languages though I believe. There an exception bubbles up the stack of error handlers until it reaches one that feels responsible for it. Or none, but then it crashes the program.


    holli

    You can lead your users to water, but alas, you cannot drown them.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2022-01-18 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (54 votes). Check out past polls.

    Notices?