about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiXSearch.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-13 07:00:36 +0000
committerEric Wong <e@80x24.org>2021-10-13 19:51:20 +0000
commit96b0a14be7e62742ad06f0a37c3cba61fe6c51e7 (patch)
tree2b1fcabfb1b23804c0d05424303f589d1d59a0f2 /lib/PublicInbox/LeiXSearch.pm
parent6bb8478c8dacf83492de3afe15a615d646f0904f (diff)
downloadpublic-inbox-96b0a14be7e62742ad06f0a37c3cba61fe6c51e7.tar.gz
treewide: use warn() or carp() instead of env->{psgi.errors}
Large chunks of our codebase and 3rd-party dependencies do not
use ->{psgi.errors}, so trying to standardize on it was a
fruitless endeavor.  Since warn() and carp() are standard
mechanism within Perl, just use that instead and simplify a
bunch of existing code.
Diffstat (limited to 'lib/PublicInbox/LeiXSearch.pm')
-rw-r--r--lib/PublicInbox/LeiXSearch.pm19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index fee1b859..ee9216fe 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -33,7 +33,7 @@ sub new {
 sub attach_external {
         my ($self, $ibxish) = @_; # ibxish = ExtSearch or Inbox
         my $desc = $ibxish->{inboxdir} // $ibxish->{topdir};
-        my $srch = $ibxish->search or
+        my $srch = $ibxish->search //
                 return warn("$desc not indexed for Xapian ($@ $!)\n");
         my @shards = $srch->xdb_shards_flat or
                 return warn("$desc has no Xapian shards\n");
@@ -184,11 +184,10 @@ sub query_one_mset { # for --threads and l2m w/o sort
         my $maxk = "external.$dir.maxuid";
         my $stop_at = $lss ? $lss->{-cfg}->{$maxk} : undef;
         if (defined $stop_at) {
-                die "$maxk=$stop_at has multiple values" if ref $stop_at;
-                my @e;
-                local $SIG{__WARN__} = sub { push @e, @_ };
-                $stop_at += 0;
-                return warn("$maxk=$stop_at: @e") if @e;
+                ref($stop_at) and
+                        return warn("$maxk=$stop_at has multiple values\n");
+                ($stop_at =~ /[^0-9]/) and
+                        return warn("$maxk=$stop_at not numeric\n");
         }
         my $first_ids;
         do {
@@ -392,12 +391,11 @@ sub query_remote_mboxrd {
                 }
                 $err = '';
                 if (-s $cerr) {
-                        seek($cerr, 0, SEEK_SET) or
+                        seek($cerr, 0, SEEK_SET) //
                                         warn "seek($cmd stderr): $!";
                         $err = do { local $/; <$cerr> } //
                                         warn "read($cmd stderr): $!";
-                        truncate($cerr, 0) or
-                                        warn "truncate($cmd stderr): $!";
+                        truncate($cerr, 0) // warn "truncate($cmd stderr): $!";
                 }
                 next if (($? >> 8) == 22 && $err =~ /\b404\b/);
                 $uri->query_form(q => $qstr);
@@ -423,9 +421,8 @@ sub query_done { # EOF callback for main daemon
         if (my $lxs = delete $lei->{lxs}) {
                 $lxs->wq_wait_old(\&xsearch_done_wait, $lei);
         }
-        if ($lei->{opt}->{'mail-sync'} && !$lei->{sto}) {
+        ($lei->{opt}->{'mail-sync'} && !$lei->{sto}) and
                 warn "BUG: {sto} missing with --mail-sync";
-        }
         $lei->sto_done_request if $lei->{sto};
         my $wait = $lei->{v2w} ? $lei->{v2w}->wq_do('done') : undef;
         $lei->{ovv}->ovv_end($lei);