Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Problem w/overloading and Carp::confess

by pjf (Curate)
on Nov 14, 2001 at 07:36 UTC ( #125234=note: print w/replies, xml ) Need Help??


in reply to Problem w/overloading and Carp::confess

The problem here, as you no doubt guessed, is that somewhere in the guts of Carp we attempt to stringify your object again, kicking off the asString method (yet again) to try and do this.

The solution here is to detect when that's happened and return a static string, rather than calling confess again. Here's an example:

sub asString { return __PACKAGE__ if (caller)[1] =~ /Carp/; confess; }

That nicely breaks the recursion. Discovering why Carp is trying to stringify your object is left as an exercise for the reader. ;)

Cheers,
Paul

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://125234]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2016-12-06 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (96 votes). Check out past polls.