Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
No::Worries::Die(3)   User Contributed Perl Documentation  No::Worries::Die(3)

NAME
       No::Worries::Die	- error	handling without worries

SYNOPSIS
	 use No::Worries::Die qw(dief handler);

	 open($fh, "<",	$path) or dief("cannot open(%s): %s", $path, $!);
	 ... not reached in case of failure ...

	 $ ./myprog
	 myprog: cannot	open(foo): No such file	or directory

	 $ NO_WORRIES=confess ./myprog
	 myprog: cannot	open(foo): No such file	or directory at	myprog line 16
	     main::test() called at ./myprog line 19

DESCRIPTION
       This module eases error handling	by providing a convenient wrapper
       around die() with sprintf()-like	API. dief() is to die()	what printf()
       is to print() with, in addition,	the trimming of	leading	and trailing
       spaces.

       It also provides	a handler for die() that prepends a prefix
       ($No::Worries::Die::Prefix) to all errors. It also uses the
       "NO_WORRIES" environment	variable to find out if	Carp's croak() or
       confess() should	be used	instead	of die(). Finally, the wrapper can be
       told to also log	errors to syslog (see $No::Worries::Die::Syslog).

       This handler can	be installed simply by importing it:

	 use No::Worries::Die qw(dief handler);

       Alternatively, it can be	installed "manually":

	 use No::Worries::Die qw(dief);
	 $SIG{__DIE__} = \&No::Worries::Die::handler;

FUNCTIONS
       This module provides the	following functions (none of them being
       exported	by default):

       dief(MESSAGE)
	   report an error described by	the given MESSAGE

       dief(FORMAT, ARGUMENTS...)
	   idem	but with sprintf()-like	API

       handler(MESSAGE)
	   $SIG{__DIE__} compatible error handler (this	function cannot	be
	   imported)

GLOBAL VARIABLES
       This module uses	the following global variables (none of	them being
       exported):

       $Prefix
	   prefix to prepend to	all errors (default: the program name)

       $Syslog
	   true	if errors should also be sent to syslog	using
	   No::Worries::Syslog's syslog_error()	(default: false)

ENVIRONMENT VARIABLES
       This module uses	the "NO_WORRIES" environment variable to control how
       errors should be	reported. Supported values are:

       "croak"
	   Carp's croak() will be used instead of die()

       "confess"
	   Carp's confess() will be used instead of die()

SEE ALSO
       Carp, No::Worries, No::Worries::Syslog, No::Worries::Warn.

AUTHOR
       Lionel Cons <http://cern.ch/lionel.cons>

       Copyright (C) CERN 2012-2019

perl v5.32.1			  2019-04-03		   No::Worries::Die(3)

NAME | SYNOPSIS | DESCRIPTION | FUNCTIONS | GLOBAL VARIABLES | ENVIRONMENT VARIABLES | SEE ALSO | AUTHOR

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=No::Worries::Die&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help