]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
gzip_filter: use carp in ->bail for failure checks
authorEric Wong <e@80x24.org>
Wed, 12 Apr 2023 00:12:59 +0000 (00:12 +0000)
committerEric Wong <e@80x24.org>
Wed, 12 Apr 2023 02:26:11 +0000 (02:26 +0000)
carp is more useful since it shows the perspective of the caller
and can be made to show a full backtrace with
PERL5OPT=-MCarp=verbose

lib/PublicInbox/GzipFilter.pm

index a11ba73fa5b13ae5c680f9664f0f382a11466022..a37080c8f859a3c5c1eba9b9a5f87df3b0fc56bc 100644 (file)
@@ -18,6 +18,7 @@ use Compress::Raw::Zlib qw(Z_OK);
 use PublicInbox::CompressNoop;
 use PublicInbox::Eml;
 use PublicInbox::GitAsyncCat;
+use Carp qw(carp);
 
 our @EXPORT_OK = qw(gzf_maybe);
 my %OPT = (-WindowBits => 15 + 16, -AppendOutput => 1);
@@ -173,16 +174,13 @@ sub close {
 
 sub bail  {
        my $self = shift;
-       if (my $env = $self->{env}) {
-               warn @_, "\n";
-               my $http = $env->{'psgix.io'} or return; # client abort
-               eval { $http->close }; # should hit our close
-               warn "E: error in http->close: $@" if $@;
-               eval { $self->close }; # just in case...
-               warn "E: error in self->close: $@" if $@;
-       } else {
-               warn @_, "\n";
-       }
+       carp @_;
+       my $env = $self->{env} or return;
+       my $http = $env->{'psgix.io'} or return; # client abort
+       eval { $http->close }; # should hit our close
+       carp "E: error in http->close: $@" if $@;
+       eval { $self->close }; # just in case...
+       carp "E: error in self->close: $@" if $@;
 }
 
 # this is public-inbox-httpd-specific