The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Trace::Mask::Carp - Trace::Mask tools for masking Carp traces

DESCRIPTION

This module can be used to apply Trace::Mask behavior to traces from the Carp module.

SYNOPSIS

LEXICAL

You can import confess(), cluck(), and longmess() from this module, this will mask traces produced from these functions in your module, but will not effect any other modules traces. This is the safest way to use this module.

    use Trace::Mask::Carp qw/confess cluck longmess mask/;

    ...

    confess "XXX"; # throws an exception with a masked trace

    # Any traces produced inside the block below, regardless of what module
    # calls confess/cluck/longmess, will be masked.
    mask {
        ...
    };

HANDLERS

THIS HAS GLOBAL CONSEQUENCES!!!

This will put handlers into $SIG{__WARN__} and $SIG{__DIE__} that will mask Carp traces no matter where they are generated.

    use Trace::Mask::Carp '-global'

Note: This is useful in a test, script, app, psgi file, etc, but should NEVER be used by a cpan module or library.

OVERRIDE

THIS HAS GLOBAL CONSEQUENCES!!!

This will redefine confess(), cluck(), and longmess() in Carp itself. This will make it so that any modules that import these functions from Carp will get the masked versions. This will not effect already loaded modules!

    use Trace::Mask::Carp '-wrap'

Note: This is useful in a test, script, app, psgi file, etc, but should NEVER be used by a cpan module or library.

IMPORT OPTIONS

FLAGS

-global

Add global handlers to $SIG{__WARN__} and $SIG{__DIE__} that mask traces coming from carp.

-wrap

Modify longmess(), confess(), and cluck() in Carp itself so that any modules that load carp will get the mask versions. This will nto effect any modules that have already loaded carp.

EXPORTS

Note: All exports are optional, you must request them if you want them.

$trace_string = longmess($message)
confess($error)
cluck($warning)

These are basically wrappers around the Carp functions of the same name. These will get the trace from Carp, then mask it.

mask { ... }

This will set $SIG{__WARN__} and $SIG{__DIE__} for the code in the block. This means that traces generated inside the mask block will be masked, but traces outside the block will not be effected.

$hr = parse_carp_line($line)

Returns a hashref with information that can be gathered from the line of carp output. This typically includes the file and line number. It may also include an error message or a subroutine name, and any arguments that were passed into the sub when it was called.

$masked_trace = mask_trace($trace)
$masked_trace = mask_trace($trace, $subname)

$subname should be 'confess', 'longmess', or 'cluck' typically, but is also optional.

This takes a trace from Carp (string form) and returns the masked form.

SOURCE

The source code repository for Trace-Mask can be found at http://github.com/exodist/Trace-Mask.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html