summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common/Various.pm11
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);