Trace::Mask::Carp(3)

πŸ“¦
version 0.000008 Β· 2 versions
, in fedora 43

πŸ’… Trace::Mask::Carp β€” the manual, but make it make sense

okay bestie, welcome to the Trace::Mask::Carp page πŸ’– this is a User Contributed Perl Documentation situation, and it's about the module Trace::Mask::Carp. buckle up, it's actually so good.


✨ NAME ✨

Trace::Mask::Carp β€” the Trace::Mask tools for masking Carp traces, no cap πŸŽ€


🌸 DESCRIPTION 🌸

so like, this module lets you apply Trace::Mask behavior to traces coming out of the Carp module. that's it. that's the whole vibe. πŸ¦‹


πŸ‘‘ SYNOPSIS πŸ‘‘

πŸ’– LEXICAL πŸ’–

okay so you can import confess(), cluck(), and longmess() straight from this module, and that will mask traces produced from these functions in your module β€” but it will not effect any other modules' traces. this is the safest way to use this module, periodt. πŸ”₯

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 one drops handlers into $SIG{__WARN__} and $SIG{__DIE__} that will mask Carp traces no matter where they are generated. like, everywhere. it's giving main character energy but for your whole process.

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. i said what i said. πŸ’…

πŸ™ˆ OVERRIDE πŸ™ˆ

THIS HAS GLOBAL CONSEQUENCES!!! πŸ’€

this one straight up redefines confess(), cluck(), and longmess() inside Carp itself. so any modules that import these functions from Carp will get the masked versions instead. lowkey unhinged. highkey iconic.

important caveat though: 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. same energy as before, bestie. πŸŽ€

⭐ IMPORT OPTIONS ⭐

πŸŽ€ FLAGS πŸŽ€

  • -global β€” adds global handlers to $SIG{__WARN__} and $SIG{__DIE__} that mask traces coming from carp. yes, globally. yes, everywhere. 🌈
  • -wrap β€” modifies 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. (that typo is in the original, i'm just the messenger 😭)

🧚 EXPORTS 🧚

Note: all exports are optional, you must request them if you want them. no surprise gifts here. πŸ“
  • $trace_string = longmess($message)
  • confess($error)
  • cluck($warning)

these are basically wrappers around the Carp functions of the same name, bestie. they get the trace from Carp, then mask it. slay. πŸ’…

  • mask { ... } β€” this sets $SIG{__WARN__} and $SIG{__DIE__} for the code inside the block. so traces generated inside the mask block get masked, but traces outside the block are not effected. boundaries, we love them. ✨
  • $hr = parse_carp_line($line) β€” returns a hashref with all the info you can gather from that one line of carp output. typically that includes the file and line number. it may also include an error message or a subroutine name, plus any arguments that were passed into the sub when it was called. detective work fr fr πŸ”
  • $masked_trace = mask_trace($trace)
  • $masked_trace = mask_trace($trace, $subname)

$subname should typically be 'confess', 'longmess', or 'cluck', but it's also optional. this takes a trace from Carp (string form) and hands you back the masked form. glow-up complete. πŸ‘‘


πŸ”₯ SOURCE πŸ”₯

the source code repository for Trace-Mask can be found at http://github.com/exodist/Trace-Mask. go peek, it's right there. 🫢


πŸ’œ MAINTAINERS πŸ’œ

Chad Granum <exodist@cpan.org>


🌈 AUTHORS 🌈

Chad Granum <exodist@cpan.org>


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


and that's the whole page, bestie πŸ’– this was Trace::Mask::Carp(3) from perl v5.42.0, dated 2025-07-25 β€” go mask some traces, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from