about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-14 13:16:04 +0000
committerEric Wong <e@80x24.org>2021-10-15 02:23:23 +0000
commitac474b431a77107fe8994c94806864bab2bc7fa9 (patch)
tree47ae1d8e8526b39df5ae130879d621301cd7ac8c /lib/PublicInbox/Git.pm
parentcdc569fa2ffcf57e1ebd37621d4d07a9b303c38f (diff)
downloadpublic-inbox-ac474b431a77107fe8994c94806864bab2bc7fa9.tar.gz
We make $req a reference upon retrying, but
"SCALAR(...)" in error messages isn't helpful, so
dereference the scalar ref.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 7c08be47..016dd2ae 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -19,7 +19,7 @@ use Time::HiRes qw(stat);
 use PublicInbox::Spawn qw(popen_rd spawn);
 use PublicInbox::Tmpfile;
 use IO::Poll qw(POLLIN);
-use Carp qw(croak);
+use Carp qw(croak carp);
 use Digest::SHA ();
 use PublicInbox::DS qw(dwaitpid);
 our @EXPORT_OK = qw(git_unquote git_quote);
@@ -228,7 +228,7 @@ sub cat_async_step ($$) {
         }
         $self->{rbuf} = $rbuf if $$rbuf ne '';
         eval { $cb->($bref, $oid, $type, $size, $arg) };
-        async_err($self, "E: cat $req ($oid) $@") if $@;
+        async_err($self, $req, $oid, $@, 'cat') if $@;
 }
 
 sub cat_async_wait ($) {
@@ -274,7 +274,7 @@ sub check_async_step ($$) {
         }
         $self->{rbuf_c} = $rbuf if $$rbuf ne '';
         eval { $cb->($hex, $type, $size, $arg, $self) };
-        async_err($self, "E: check $req ($hex) $@") if $@;
+        async_err($self, $req, $hex, $@, 'check') if $@;
 }
 
 sub check_async_wait ($) {
@@ -342,6 +342,7 @@ sub async_abort ($) {
                         my $q = $self->{"inflight$c"};
                         while (@$q) {
                                 my ($req, $cb, $arg) = splice(@$q, 0, 3);
+                                $req = $$req if ref($req);
                                 $req =~ s/ .*//; # drop git_dir for Gcf2Client
                                 eval { $cb->(undef, $req, undef, undef, $arg) };
                                 warn "E: (in abort) $req: $@" if $@;
@@ -359,10 +360,11 @@ sub fail { # may be augmented in subclasses
         croak(ref($self) . ' ' . ($self->{git_dir} // '') . ": $msg");
 }
 
-sub async_err ($$) {
-        my ($self, $msg) = @_;
-        return warn($msg) if $async_warn;
-        $self->fail($msg);
+sub async_err ($$$$$) {
+        my ($self, $req, $oid, $err, $action) = @_;
+        $req = $$req if ref($req); # retried
+        my $msg = "E: $action $req ($oid): $err";
+        $async_warn ? carp($msg) : $self->fail($msg);
 }
 
 # $git->popen(qw(show f00)); # or