1Carp::Clan(3)         User Contributed Perl Documentation        Carp::Clan(3)
2
3
4

NAME

6       Carp::Clan - Report errors from perspective of caller of a "clan" of
7       modules
8

VERSION

10       version 6.08
11

SYNOPSIS

13        carp    - warn of errors (from perspective of caller)
14
15        cluck   - warn of errors with stack backtrace
16
17        croak   - die of errors (from perspective of caller)
18
19        confess - die of errors with stack backtrace
20
21           use Carp::Clan qw(^MyClan::);
22           croak "We're outta here!";
23
24           use Carp::Clan;
25           confess "This is how we got here!";
26

DESCRIPTION

28       This module is based on ""Carp.pm"" from Perl 5.005_03. It has been
29       modified to skip all package names matching the pattern given in the
30       "use" statement inside the ""qw()"" term (or argument list).
31
32       Suppose you have a family of modules or classes named "Pack::A",
33       "Pack::B" and so on, and each of them uses ""Carp::Clan qw(^Pack::);""
34       (or at least the one in which the error or warning gets raised).
35
36       Thus when for example your script "tool.pl" calls module "Pack::A", and
37       module "Pack::A" calls module "Pack::B", an exception raised in module
38       "Pack::B" will appear to have originated in "tool.pl" where "Pack::A"
39       was called, and not in "Pack::A" where "Pack::B" was called, as the
40       unmodified ""Carp.pm"" would try to make you believe ":-)".
41
42       This works similarly if "Pack::B" calls "Pack::C" where the exception
43       is raised, et cetera.
44
45       In other words, this blames all errors in the ""Pack::*"" modules on
46       the user of these modules, i.e., on you. ";-)"
47
48       The skipping of a clan (or family) of packages according to a pattern
49       describing its members is necessary in cases where these modules are
50       not classes derived from each other (and thus when examining @ISA - as
51       in the original ""Carp.pm"" module - doesn't help).
52
53       The purpose and advantage of this is that a "clan" of modules can work
54       together (and call each other) and throw exceptions at various depths
55       down the calling hierarchy and still appear as a monolithic block (as
56       though they were a single module) from the perspective of the caller.
57
58       In case you just want to ward off all error messages from the module in
59       which you ""use Carp::Clan"", i.e., if you want to make all error
60       messages or warnings to appear to originate from where your module was
61       called (this is what you usually used to ""use Carp;"" for ";-)"),
62       instead of in your module itself (which is what you can do with a "die"
63       or "warn" anyway), you do not need to provide a pattern, the module
64       will automatically provide the correct one for you.
65
66       I.e., just ""use Carp::Clan;"" without any arguments and call "carp" or
67       "croak" as appropriate, and they will automatically defend your module
68       against all blames!
69
70       In other words, a pattern is only necessary if you want to make several
71       modules (more than one) work together and appear as though they were
72       only one.
73
74   Forcing a Stack Trace
75       As a debugging aid, you can force ""Carp::Clan"" to treat a "croak" as
76       a "confess" and a "carp" as a "cluck". In other words, force a detailed
77       stack trace to be given. This can be very helpful when trying to
78       understand why, or from where, a warning or error is being generated.
79
80       This feature is enabled either by "importing" the non-existent symbol
81       'verbose', or by setting the global variable "$Carp::Clan::Verbose" to
82       a true value.
83
84       You would typically enable it by saying
85
86           use Carp::Clan qw(verbose);
87
88       Note that you can both specify a "family pattern" and the string
89       "verbose" inside the ""qw()"" term (or argument list) of the "use"
90       statement, but consider that a pattern of packages to skip is pointless
91       when "verbose" causes a full stack trace anyway.
92

BUGS

94       The ""Carp::Clan"" routines don't handle exception objects currently.
95       If called with a first argument that is a reference, they simply call
96       ""die()"" or ""warn()"", as appropriate.
97
98       Bugs may be submitted through the RT bug tracker
99       <https://rt.cpan.org/Public/Dist/Display.html?Name=Carp-Clan> (or
100       bug-Carp-Clan@rt.cpan.org <mailto:bug-Carp-Clan@rt.cpan.org>).
101

AUTHOR

103       Steffen Beyer <STBEY@cpan.org>
104

CONTRIBUTORS

106       •   Karen Etheridge <ether@cpan.org>
107
108       •   Joshua ben Jore <jjore@cpan.org>
109
110       •   Kent Fredric <kentnl@cpan.org>
111
113       This software is copyright (c) 2001 by Steffen Beyer, Joshua ben Jore.
114
115       This is free software; you can redistribute it and/or modify it under
116       the same terms as the Perl 5 programming language system itself.
117
118
119
120perl v5.36.0                      2022-07-22                     Carp::Clan(3)
Impressum