Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Exceptions vs Context Objects

by rjray (Chaplain)
on Mar 31, 2006 at 07:15 UTC ( #540399=note: print w/replies, xml ) Need Help??


in reply to Exceptions vs Context Objects

Seems to me that the old stand-by of having the plugins/events call die, and having the dispatcher use eval when calling the event-handlers. Then you can catch the die's and react accordingly. And writers of these plugins can just use a familiar idiom to signal problems.

--rjray

Replies are listed 'Best First'.
Re^2: Exceptions vs Context Objects
by tirwhan (Abbot) on Mar 31, 2006 at 08:47 UTC

    eval is exactly equivalent to the concept of catching exceptions in other (more pompous ;-) languages. What the OP is talking about is returning an exception object in $@ instead of just an error message. This object can then be inspected, modified and rethrown, or what have you, which gives a bit more flexibility in your error handling. Since this seems to be pretty much what the OP is after, I'd say yeah, exceptions are probably the way forward for this module.


    All dogma is stupid.

      I understand that. It's a matter of how complex he wants to make it for those that write the extensions. They can die with a string or with a blessed object. The advantage to the object approach is that he can also manage the "just how serious is this error" question, as well.

      True exception handling is one thing I like about other (more pompous) languages. Sometimes I really miss it in Perl...

      --rjray

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-05-25 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?