1Trace::Mask::Carp(3) User Contributed Perl Documentation Trace::Mask::Carp(3)
2
3
4
6 Trace::Mask::Carp - Trace::Mask tools for masking Carp traces
7
9 This module can be used to apply Trace::Mask behavior to traces from
10 the Carp module.
11
13 LEXICAL
14 You can import "confess()", "cluck()", and "longmess()" from this
15 module, this will mask traces produced from these functions in your
16 module, but will not effect any other modules traces. This is the
17 safest way to use this module.
18
19 use Trace::Mask::Carp qw/confess cluck longmess mask/;
20
21 ...
22
23 confess "XXX"; # throws an exception with a masked trace
24
25 # Any traces produced inside the block below, regardless of what module
26 # calls confess/cluck/longmess, will be masked.
27 mask {
28 ...
29 };
30
31 HANDLERS
32 THIS HAS GLOBAL CONSEQUENCES!!!
33
34 This will put handlers into $SIG{__WARN__} and $SIG{__DIE__} that will
35 mask Carp traces no matter where they are generated.
36
37 use Trace::Mask::Carp '-global'
38
39 Note: This is useful in a test, script, app, psgi file, etc, but should
40 NEVER be used by a cpan module or library.
41
42 OVERRIDE
43 THIS HAS GLOBAL CONSEQUENCES!!!
44
45 This will redefine "confess()", "cluck()", and "longmess()" in Carp
46 itself. This will make it so that any modules that import these
47 functions from Carp will get the masked versions. This will not effect
48 already loaded modules!
49
50 use Trace::Mask::Carp '-wrap'
51
52 Note: This is useful in a test, script, app, psgi file, etc, but should
53 NEVER be used by a cpan module or library.
54
56 FLAGS
57 -global
58 Add global handlers to $SIG{__WARN__} and $SIG{__DIE__} that mask
59 traces coming from carp.
60
61 -wrap
62 Modify "longmess()", "confess()", and "cluck()" in Carp itself so
63 that any modules that load carp will get the mask versions. This
64 will nto effect any modules that have already loaded carp.
65
66 EXPORTS
67 Note: All exports are optional, you must request them if you want them.
68
69 $trace_string = longmess($message)
70 confess($error)
71 cluck($warning)
72 These are basically wrappers around the Carp functions of the same
73 name. These will get the trace from Carp, then mask it.
74
75 mask { ... }
76 This will set $SIG{__WARN__} and $SIG{__DIE__} for the code in the
77 block. This means that traces generated inside the mask block will
78 be masked, but traces outside the block will not be effected.
79
80 $hr = parse_carp_line($line)
81 Returns a hashref with information that can be gathered from the
82 line of carp output. This typically includes the file and line
83 number. It may also include an error message or a subroutine name,
84 and any arguments that were passed into the sub when it was called.
85
86 $masked_trace = mask_trace($trace)
87 $masked_trace = mask_trace($trace, $subname)
88 $subname should be 'confess', 'longmess', or 'cluck' typically, but
89 is also optional.
90
91 This takes a trace from Carp (string form) and returns the masked
92 form.
93
95 The source code repository for Trace-Mask can be found at
96 http://github.com/exodist/Trace-Mask.
97
99 Chad Granum <exodist@cpan.org>
100
102 Chad Granum <exodist@cpan.org>
103
105 Copyright 2015 Chad Granum <exodist7@gmail.com>.
106
107 This program is free software; you can redistribute it and/or modify it
108 under the same terms as Perl itself.
109
110 See http://www.perl.com/perl/misc/Artistic.html
111
112
113
114perl v5.34.0 2021-07-23 Trace::Mask::Carp(3)