Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Carp / Clan.pod
CommitLineData
86530b38
AT
1
2=head1 NAME
3
4Carp::Clan - Report errors from perspective of caller of a "clan" of modules
5
6=head1 SYNOPSIS
7
8 carp - warn of errors (from perspective of caller)
9
10 cluck - warn of errors with stack backtrace
11
12 croak - die of errors (from perspective of caller)
13
14 confess - die of errors with stack backtrace
15
16 use Carp::Clan qw(^MyClan::);
17 croak "We're outta here!";
18
19 use Carp::Clan;
20 confess "This is how we got here!";
21
22=head1 DESCRIPTION
23
24This module is based on "C<Carp.pm>" from Perl 5.005_03. It has been
25modified to skip all package names matching the pattern given in
26the "use" statement inside the "C<qw()>" term (or argument list).
27
28Suppose you have a family of modules or classes named "Pack::A",
29"Pack::B" and so on, and each of them uses "C<Carp::Clan qw(^Pack::);>"
30(or at least the one in which the error or warning gets raised).
31
32Thus when for example your script "tool.pl" calls module "Pack::A",
33and module "Pack::A" calls module "Pack::B", an exception raised in
34module "Pack::B" will appear to have originated in "tool.pl" where
35"Pack::A" was called, and not in "Pack::A" where "Pack::B" was called,
36as the unmodified "C<Carp.pm>" would try to make you believe C<:-)>.
37
38This works similarly if "Pack::B" calls "Pack::C" where the
39exception is raised, etcetera.
40
41In other words, this blames all errors in the "C<Pack::*>" modules
42on the user of these modules, i.e., on you. C<;-)>
43
44The skipping of a clan (or family) of packages according to a pattern
45describing its members is necessary in cases where these modules are
46not classes derived from each other (and thus when examining C<@ISA>
47(as in the original "C<Carp.pm>" module) doesn't help).
48
49The purpose and advantage of this is that a "clan" of modules can work
50together (and call each other) and throw exceptions at various depths
51down the calling hierarchy and still appear as a monolithic block (as
52though they were a single module) from the perspective of the caller.
53
54In case you just want to ward off all error messages from the module
55in which you "C<use Carp::Clan>", i.e., if you want to make all error
56messages or warnings to appear to originate from where your module
57was called (this is what you usually used to "C<use Carp;>" for C<;-)>),
58instead of in your module itself (which is what you can do with a
59"die" or "warn" anyway), you do not need to provide a pattern,
60the module will automatically provide the correct one for you.
61
62I.e., just "C<use Carp::Clan;>" without any arguments and call "carp"
63or "croak" as appropriate, and they will automatically defend your
64module against all blames!
65
66In other words, a pattern is only necessary if you want to make
67several modules (more than one) work together and appear as though
68they were only one.
69
70=head2 Forcing a Stack Trace
71
72As a debugging aid, you can force "C<Carp::Clan>" to treat a "croak" as
73a "confess" and a "carp" as a "cluck". In other words, force a detailed
74stack trace to be given. This can be very helpful when trying to
75understand why, or from where, a warning or error is being generated.
76
77This feature is enabled either by "importing" the non-existent symbol
78'verbose', or by setting the global variable "C<$Carp::Clan::Verbose>"
79to a true value.
80
81You would typically enable it by saying
82
83 use Carp::Clan qw(verbose);
84
85Note that you can both specify a "family pattern" and the string "verbose"
86inside the "C<qw()>" term (or argument list) of the "use" statement, but
87consider that a pattern of packages to skip is pointless when "verbose"
88causes a full stack trace anyway.
89
90=head1 BUGS
91
92The "C<Carp::Clan>" routines don't handle exception objects currently.
93If called with a first argument that is a reference, they simply
94call "C<die()>" or "C<warn()>", as appropriate.
95