Carp(3)

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

πŸ’– Carp(3) β€” Gtk2::Ex::Carp πŸ’–

okay bestie, sit down, hydrate, because this is a Perl module from the Gtk2::Ex fam and it is lowkey iconic ✨


🌸 NAME 🌸

Gtk2::Ex::Carp β€” GTK+ friendly die() and warn() functions. fr fr, that's the whole vibe. πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

        use Gtk2::Ex::Carp;

        # these override the standard Perl functions:

        warn('i told you not to push that button!');

        die('an ignominious death');

        # new functions for showing extended error information:

        # like warn(), but shows a dialog with extra information
        # in an expandable text entry:
        worry($SHORT_MESSAGE, $EXTENDED_INFORMATION);

        # like worry(), but fatal:
        wail($SHORT_MESSAGE, $EXTENDED_INFORMATION);

the way that second comment is literally a whole mood πŸ˜­πŸ’…


🌈 DESCRIPTION 🌈

So this module exports four functions, okay? Two of them straight-up override the standard die() and warn(), and two more let you do ✨extended✨ error reporting. When you call any of them, you get a user-friendly message dialog window. Not a scary terminal wall of red text. A dialog. Gorgeous. πŸ’–

The die() function in this module actually replaces the core die() function, so any modules you've loaded that die will use the former instead of the latter. Yes, that's real, that's the whole point. die() will also print the error message to "STDERR" and will exit the program (with the appropriate exit code) when the dialog is dismissed.

The warn() function will also print a message to "STDERR", but β€” plot twist β€” it will allow the program to continue running when the dialog is dismissed. 🫢


πŸ’œ EXTRA FUNCTIONS πŸ’œ

The worry() and wail() functions behave just like warn() and die(), respectively β€” same energy, different font β€” except that they let you provide additional information. A second argument, which can contain additional error information, is used to fill a text box inside an expander. so it's like a little collapsible surprise of context, love that for you 🎁


🧚 HANDLING GLIB EXCEPTIONS 🧚

This module also installs warn() as a Glib exception handler. Any unhandled exceptions will be presented to the user in a warning dialog. no cap. πŸ’€


⭐ PROGRAM FLOW ⭐

heads up bestie: all the functions in this module create dialogs and use the run() method, so the standard Glib main loop is blocked until the user responds to the dialog. like, fully paused. main character is the dialog now. πŸ‘‘

πŸŽ€ LOCALISATION ISSUES πŸŽ€

The dialogs that are created use the standard GNOME layout, with a bold "title" label above the main message. The text for these labels is taken from two package variables that may be altered to suit your needs:

        $Gtk2::Ex::Carp::FATAL_ERROR_MESSAGE            = 'Fatal Error';
        $Gtk2::Ex::Carp::WARNING_ERROR_MESSAGE          = 'Warning';
        $Gtk2::Ex::Carp::EXTENDED_EXPANDER_LABEL        = 'Details:';

(yes it says "two package variables" and then shows three. we don't gatekeep, we just report 🫢)

However, if the "Locale::gettext" module is available on the system, and your application uses it, these variables will be automagically translated, as long as these default values are translated in your .mo files. βœ¨πŸ¦‹


🌸 SEE ALSO 🌸

  • Gtk2
  • Carp
  • Locale::gettext

the holy trinity, honestly πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Gavin Brown (gavin dot brown at uk dot com) β€” legend behavior, we love to see it πŸŽ€


(c) 2005 Gavin Brown. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 🌈


and that's the whole page, bestie β€” this was perl v5.42.0, dated 2025-07-25, from the Carp(3) manual, User Contributed Perl Documentation section. go forth and worry() responsibly πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from