diff options
author | Eric Wong <e@80x24.org> | 2021-10-16 01:00:58 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-10-16 01:42:52 +0000 |
commit | 7893b78fd691ef1e9b503e44174ff53278b02554 (patch) | |
tree | 2137c1210e761c156d987c94053989c905e2c5da /lib/PublicInbox/LeiQuery.pm | |
parent | 13e60633b0a4fd31f224bf172c976e8d921ec609 (diff) | |
download | public-inbox-7893b78fd691ef1e9b503e44174ff53278b02554.tar.gz |
Relying on $lei->fail is unsustainable since there'll always be parts of our code and dependencies which can trigger die() and break the event loop.
Diffstat (limited to 'lib/PublicInbox/LeiQuery.pm')
-rw-r--r-- | lib/PublicInbox/LeiQuery.pm | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index c65b00ca..ec2ece05 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -55,19 +55,17 @@ sub _start_query { # used by "lei q" and "lei up" } sub qstr_add { # PublicInbox::InputPipe::consume callback for --stdin - my ($self) = @_; # $_[1] = $rbuf - if (defined($_[1])) { - $_[1] eq '' and return eval { - $self->fchdir or return; - $self->{mset_opt}->{q_raw} = $self->{mset_opt}->{qstr}; - $self->{lse}->query_approxidate($self->{lse}->git, - $self->{mset_opt}->{qstr}); - _start_query($self); - }; - $self->{mset_opt}->{qstr} .= $_[1]; - } else { - $self->fail("error reading stdin: $!"); - } + my ($lei) = @_; # $_[1] = $rbuf + $_[1] // $lei->fail("error reading stdin: $!"); + return $lei->{mset_opt}->{qstr} .= $_[1] if $_[1] ne ''; + eval { + $lei->fchdir; + $lei->{mset_opt}->{q_raw} = $lei->{mset_opt}->{qstr}; + $lei->{lse}->query_approxidate($lei->{lse}->git, + $lei->{mset_opt}->{qstr}); + _start_query($lei); + }; + $lei->fail($@) if $@; } sub lxs_prepare { |