From 4c9ecb71cf4ebf3d7cbcb89f7183c9204d267c8b Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 12 Oct 2021 09:03:46 -0700 Subject: [PATCH] add internal fault check for tokens out of order --- lib/Perl/Tidy/FileWriter.pm | 39 +++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/Perl/Tidy/FileWriter.pm b/lib/Perl/Tidy/FileWriter.pm index d8a00ec5..ad066bd3 100644 --- a/lib/Perl/Tidy/FileWriter.pm +++ b/lib/Perl/Tidy/FileWriter.pm @@ -70,6 +70,39 @@ BEGIN { }; } +sub Die { + my ($msg) = @_; + Perl::Tidy::Die($msg); + return; +} + +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); + + Die(<[_logger_object_]; @@ -268,15 +301,13 @@ $str This is probably due to a recent programming change and needs to be fixed. EOM - # FIXME: it would be best to set a 'severe_error' flag here and - # tell caller to output the original file + if (DEVEL_MODE) { Fault($msg) } + $self->warning($msg); # Only issue this warning once $self->[_K_sequence_error_msg_] = $msg; - # stop here in DEVEL mode so this issue doesn't get missed - DEVEL_MODE && Perl::Tidy::Die($msg); } } $self->[_K_last_arrival_] = $K; -- 2.39.5