diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-07-25 11:01:15 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-07-25 11:01:15 +0000 |
commit | c1ce79a112218c16ae4d8b15a00038dcc5d55066 (patch) | |
tree | 3e12c9824bc2dbd144c25fd27a18a52e8fc497fa /MDK/Common | |
parent | fcac348ec6d89f560a0f21612a071b27929a370c (diff) | |
download | perl-MDK-Common-c1ce79a112218c16ae4d8b15a00038dcc5d55066.tar perl-MDK-Common-c1ce79a112218c16ae4d8b15a00038dcc5d55066.tar.gz perl-MDK-Common-c1ce79a112218c16ae4d8b15a00038dcc5d55066.tar.bz2 perl-MDK-Common-c1ce79a112218c16ae4d8b15a00038dcc5d55066.tar.xz perl-MDK-Common-c1ce79a112218c16ae4d8b15a00038dcc5d55066.zip |
- add Various::internal_error
- export Various::noreturn
Diffstat (limited to 'MDK/Common')
-rw-r--r-- | MDK/Common/Various.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/MDK/Common/Various.pm b/MDK/Common/Various.pm index 0d8f008..6489f9d 100644 --- a/MDK/Common/Various.pm +++ b/MDK/Common/Various.pm @@ -68,6 +68,11 @@ gives main::g() called from /tmp/t.pl:2 main::f() called from /tmp/t.pl:4 + +=item internal_error(STRING) + +another way to C<die> with a nice error message and a backtrace + =item noreturn() use this to ensure nobody uses the return value of the function. eg: @@ -93,7 +98,7 @@ package MDK::Common::Various; use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK); @ISA = qw(Exporter); -@EXPORT_OK = qw(first second top to_bool to_int to_float bool2text bool2yesno text2bool chomp_ backtrace); +@EXPORT_OK = qw(first second top to_bool to_int to_float bool2text bool2yesno text2bool chomp_ backtrace internal_error noreturn); %EXPORT_TAGS = (all => [ @EXPORT_OK ]); @@ -119,6 +124,10 @@ sub backtrace { $s; } +sub internal_error { + die "INTERNAL ERROR: $_[0]\n" . backtrace(); +} + sub noreturn { if (defined wantarray) { my ($package, $file, $line, $func) = caller(1); |