Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re (tilly) 1: Confusion about properly using Carp

by tilly (Archbishop)
on Mar 02, 2002 at 19:35 UTC ( [id://148870]=note: print w/replies, xml ) Need Help??


in reply to Confusion about properly using Carp

When Perl 5.8 comes out you will be able to control this behaviour through use of @CARP_NOT.

In the meantime the only solutions are to either replace the offending functions with your own (in general a bad idea) or be sure that you inherit from all classes that errors might come from.

Some explanation might be in order.

The reason is that Carp's way of finding where to report an error from is to walk the stack, looking for the first "untrusted" call. How is that determined? Well any call from a package to itself is trusted. Any call to or from a subclass is trusted. (OK, in 5.005 and earlier the implementation used a hack that didn't always do that.) Calls to and from Carp are trusted. (OK, that is the new implementation. The old one just arranged to have 2 call levels, and used goto liberally to keep it so. Blech.)

So in effect, there is a trust relationship built transitively out of whatever was in @ISA. Therefore the only way to control what would be reported where is by arranging to inherit from the class you don't want to report errors from. The change in 5.8 is that if you supply @CARP_NOT, Carp uses that for establishing the trust relationship instead of @ISA. (Because inheritance and "new code" are separate concepts.)

  • Comment on Re (tilly) 1: Confusion about properly using Carp

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-18 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found