Gtk2::Ex::Carp - GTK+ friendly
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);
This module exports four functions, of which two override the standard
warn() functions, and two which allow for extended error reporting. When called, these functions display a user-friendly message dialog window.
die() function in this module actually replaces the core
die() function, so any modules you've loaded may die will use former instead of the latter.
die() will also print the error message to
STDERR and will exit the program (with the appropriate exit code) when the dialog is dismissed.
warn() function will also print a message to
STDERR, but will allow the program to continue running when the dialog is dismissed.
wail() functions behave just like
die(), respectively, except that they allow you to provide additional information. A second argument, which can contain additional error information, is used to fill a text box inside an expander.
This module also installs
warn() as a Glib exception handler. Any unhandled exceptions will be presented to the user in a warning dialog.
Note that all the functions in this module create dialogs and use the
run() method, so that the standard Glib main loop is blocked until the user responds to the dialog.
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:';
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.
Gavin Brown (gavin dot brown at uk dot com)
(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.