Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Error.pm and custom Exception

by fmerges (Chaplain)
on Feb 24, 2009 at 11:57 UTC ( #745973=note: print w/replies, xml ) Need Help??


in reply to Error.pm and custom Exception

Hi,

As said already, you don't get $self in the constructor... it's $class, so you should have:

my $self = $class->SUPER::new(...)

Beside of this, I would strongly recommend you to not use Error.pm, based on my own experience. Some reasons:

* If you forget the ; at the end of your try...catch block you will have hard time trying to find obscure bugs, what you see in the code is not what is being executed.
* You have to include in every place you want to use the try...catch syntax sugar the 'use Error qw(:try)' and not only the subclassed exeption class. You will not get compiling error, it will just not work as expected.
* Debugging is also painful, the code executed inside of the try...catch blocks are wrapped, so it makes debugging using the debugger a pain; check it out for yourself.

For these reasons I would rather recommend you to use Exception::Class instead.

Regards,

fmerges at irc.freenode.net

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://745973]
help
Chatterbox?
[Corion]: holli: Ooof :)
[hippo]: Cut should beless than 20% after tax, though. :-)
[Corion]: hippo: Yeah, but at least two years ago, it still was close enough to 20% cut
[Corion]: But I have a very positive experience with a four day workweek and a three day weekend. I can't easily go back though to full money.
[Corion]: That is easy without having to pay for a house, a wife or children though. If I had any of these, or any two of these, the decision wouldn't be that easy.
[ambrus]: wait. I understand no wife and children, but how do you not have to pay for a house?
[hippo]: I had a low-paid job about 20 years ago and seriously considered going down to a 3-day week. Would have worked 60% of the time for about 80% of the cash.
[Corion]: ambrus: Well, I pay rent, but don't own a house with variable/ unforeseeable costs

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2017-09-21 15:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (249 votes). Check out past polls.

    Notices?