Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Do you use an exception class in your Perl programs? Why or why not?

by TGI (Parson)
on Mar 14, 2010 at 01:39 UTC ( #828504=note: print w/replies, xml ) Need Help??


in reply to Re: Do you use an exception class in your Perl programs? Why or why not?
in thread Do you use an exception class in your Perl programs? Why or why not?

I've been mostly underwhelmed with exception based techniques and exception objects. Try::Tiny has resolved many of my complaints with exceptions in general, so I am using them again.

It bothers me to have to keep writing the likes of:

if( $@ =~ /some error stuff/ ) { warn "error stuff occurred"; } else { warn "some other message" ; }

An exception class system that works would remove the need for parsing data out of strings that should be available in a data structure.

I feel like Perl exceptions are kind of like Perl OO in general. The language provides a bare minimum set of features that can be used to get things done, bat can also be extended in clever ways.

We have 37 million Class::Foo modules that tried to build a better Perl object system. After years of experimentation, Moose hit the scene and has taken over.

Is exception handling in Perl ripe for the introduction of a revolutionary module like Moose? What would it look like?

Thanks for your thoughts.


TGI says moo

  • Comment on Re^2: Do you use an exception class in your Perl programs? Why or why not?
  • Download Code

Replies are listed 'Best First'.
Re^3: Do you use an exception class in your Perl programs? Why or why not?
by zwon (Abbot) on Mar 14, 2010 at 10:14 UTC
    if( $@ =~ /some error stuff/ ) { warn "error stuff occurred"; } else { warn "some other message" ; }

    As I said I usually just do

    if($@) { Oops; }
    but now you mentioned it and I remember one case when I have to examine $@ content deeper. But usually I'm avoiding this, particularly because I don't see the way to do it clean.
    I feel like Perl exceptions are kind of like Perl OO in general.
    I feel that too. The problem is that $@ may contain any object, there's no standard interface to it. If there will be a module that change this situation, that would be great.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2020-10-26 19:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (252 votes). Check out past polls.

    Notices?