X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2FPerl%2FTidy%2FFileWriter.pm;h=934d960981682affe31c9282a921073539ce9c62;hb=880633cc084e9d787eb9f760d3851c5d660db17c;hp=9a9d62f20a7517f8333c3eed95872323c1923f41;hpb=57d829ae0e2c75828f8ecc9c7139579350927dbc;p=perltidy.git diff --git a/lib/Perl/Tidy/FileWriter.pm b/lib/Perl/Tidy/FileWriter.pm index 9a9d62f..934d960 100644 --- a/lib/Perl/Tidy/FileWriter.pm +++ b/lib/Perl/Tidy/FileWriter.pm @@ -7,7 +7,7 @@ package Perl::Tidy::FileWriter; use strict; use warnings; -our $VERSION = '20210717'; +our $VERSION = '20220217'; use constant DEVEL_MODE => 0; @@ -44,7 +44,8 @@ my $MAX_NAG_MESSAGES = 6; BEGIN { - # Array index names for variables + # Array index names for variables. + # Do not combine with other BEGIN blocks (c101). my $i = 0; use constant { _line_sink_object_ => $i++, @@ -70,6 +71,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 +302,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;