Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by GrandFather (Saint)
on Jul 07, 2019 at 12:25 UTC ( #11102497=note: print w/replies, xml ) Need Help??


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

Exceptions propagate until they are handled which may be at the outermost level by Perl handling the die. Nothing between the code throwing the exception and the node handling it sees the exception.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
  • Comment on Re^3: Error codes vs die exceptions vs ...

Replies are listed 'Best First'.
Re^4: Error codes vs die exceptions vs ...
by LanX (Sage) on Jul 07, 2019 at 14:19 UTC
    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

      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.

      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://11102497]
help
Chatterbox?
and the web crawler heard nothing...

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












    Results (52 votes). Check out past polls.

    Notices?