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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I first had problems understanding the documentation in Carp, but basically the setup is:

package Foo; use strict; use Carp qw( croak ); sub do_foo { croak "Please don't give arguments to do_foo(), got '@_'" unless 0 == @_; }; package Baz; use strict; sub do_baz { Foo::do_foo( @_ ); }; package Bar; use strict; use vars qw(@CARP_NOT); @CARP_NOT=('Foo'); # we are invisible to Foo sub do_bar { my( $first,@rest )= @_; print "Got '$first', Preparing for foo(@rest)\n"; Foo::do_foo(@rest); }; package main; print "Bar\n"; Bar::do_bar('one'); # does not croak print "do_foo\n"; eval { Foo::do_foo('one','two'); }; print $@; # Please don't give arguments to do_foo(), got 'one two' at tmp.pl lin +e 34. print "do_bar\n"; eval { Bar::do_bar('one','two'); }; print $@; # Please don't give arguments to do_foo(), got 'two' at tmp.pl line 37 +. print "do_baz\n"; eval { Baz::do_baz('one','two'); }; print $@; # Please don't give arguments to do_foo() at tmp.pl line 14.

Here, the package Bar does not show up as an error location, because it sets itself up to be invisible for all errors raised by Foo. Baz does get raised as the error location in the last call, which may or may not be helpful to the user using Baz.

For a more elaborate example of this, MozRepl::RemoteObject::Instance has some helper classes for tie-ing scalars, arrays and hashes. But all errors due to operations on these should be transparent to the user and show up in the user code, which is achieved by setting up @CARP_NOT in each of the tied classes so that errors raised in MozRepl::RemoteObject::Instance never show up as originating in the helper class.


In reply to Re^4: die or croak by Corion
in thread die or croak by McA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (9)
    As of 2014-08-28 23:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (275 votes), past polls