From fc822fdb72678b7307b06407dbddb496f3405f00 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 18 Sep 2021 18:50:28 -0700 Subject: [PATCH] added sub Fault to Tokenizer.pm --- lib/Perl/Tidy/Formatter.pm | 4 ++-- lib/Perl/Tidy/Tokenizer.pm | 42 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index e3e48682..99e37ba1 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1,4 +1,4 @@ -#################################################################### +##################################################################### # # The Perl::Tidy::Formatter package adds indentation, whitespace, and # line breaks to the token stream @@ -112,7 +112,7 @@ A fault was detected at line $line0 of sub '$subroutine1' in file '$filename1' which was called from line $line1 of sub '$subroutine2' Message: '$msg' -This is probably an error introduced by a recent programming change. +This is probably an error introduced by a recent programming change. Perl::Tidy::Formatter.pm reports VERSION='$VERSION'. ============================================================================== EOM diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 4e8046a2..f2f4deb2 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -233,6 +233,35 @@ sub Die { croak "unexpected return from Perl::Tidy::Die"; } +sub Fault { + my ($msg) = @_; + + # This routine is called for errors that really should not occur + # except if there has been a bug introduced by a recent program change. + # Please add comments at calls to Fault to explain why the call + # should not occur, and where to look to fix it. + my ( $package0, $filename0, $line0, $subroutine0 ) = caller(0); + my ( $package1, $filename1, $line1, $subroutine1 ) = caller(1); + my ( $package2, $filename2, $line2, $subroutine2 ) = caller(2); + my $input_stream_name = get_input_stream_name(); + + Die(<[_logger_object_]; + if ($logger_object) { + $input_stream_name = $logger_object->get_input_stream_name(); + } + return $input_stream_name; +} + sub complain { my $msg = shift; my $logger_object = $tokenizer_self->[_logger_object_]; @@ -1666,8 +1704,8 @@ sub prepare_for_a_new_file { # Shouldn't get here if (DEVEL_MODE) { - Die(<