Keep It Simple, Stupid | |
PerlMonks |
Re (tilly) 1: Confusion about properly using Carpby tilly (Archbishop) |
on Mar 02, 2002 at 19:35 UTC ( [id://148870]=note: print w/replies, xml ) | Need Help?? |
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.)
In Section
Seekers of Perl Wisdom
|
|