From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] gzip_filter: use carp in ->bail for failure checks
Date: Sat, 8 Apr 2023 09:30:52 +0000 [thread overview]
Message-ID: <20230408093052.861102-1-e@80x24.org> (raw)
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 | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm
index a11ba73f..a37080c8 100644
--- a/lib/PublicInbox/GzipFilter.pm
+++ b/lib/PublicInbox/GzipFilter.pm
@@ -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
reply other threads:[~2023-04-08 9:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230408093052.861102-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).