diff options
author | Eric Wong <e@80x24.org> | 2023-11-09 10:09:43 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-09 21:53:53 +0000 |
commit | d974977afda1b887313e0143dfa740604b2fc740 (patch) | |
tree | ea138e290251d2293c13d5e40ff1c812f3896064 /lib/PublicInbox/LeiInput.pm | |
parent | b35530ccb929a693c4c78b02187a564a7ab5e903 (diff) | |
download | public-inbox-d974977afda1b887313e0143dfa740604b2fc740.tar.gz |
This matches the behavior we have for multi-message mbox files since we rely on ->close to detect errors on bad mboxes. This ensures we'll notice errors reading single messages from stdin. We'll also start relying more on strace error injection to test error handling.
Diffstat (limited to 'lib/PublicInbox/LeiInput.pm')
-rw-r--r-- | lib/PublicInbox/LeiInput.pm | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm index 4cd18c09..adb356c9 100644 --- a/lib/PublicInbox/LeiInput.pm +++ b/lib/PublicInbox/LeiInput.pm @@ -81,9 +81,11 @@ sub input_fh { my ($self, $ifmt, $fh, $name, @args) = @_; if ($ifmt eq 'eml') { my $buf = do { local $/; <$fh> }; - (defined($buf) && eof($fh) && close($fh)) or - return $self->{lei}->child_error(0, <<""); -error reading $name: $! + my $ok = defined($buf) ? 1 : 0; + ++$ok if eof($fh); + ++$ok if $fh->close; + $ok == 3 or return $self->{lei}->child_error($?, <<""); +error reading $name: $! (\$?=$?) PublicInbox::Eml::strip_from($buf); @@ -246,9 +248,8 @@ sub input_path_url { my $rdr = { 2 => $lei->{2} }; my $fh = popen_rd($fp, undef, $rdr); eval { $self->input_fh('eml', $fh, $input, @args) }; - my @err = ($@ ? $@ : ()); - $fh->close or push @err, "\$?=$?"; - $lei->child_error($?, "@$fp failed: @err") if @err; + my $err = $@ ? ": $@" : ''; + $lei->child_error($?, "@$fp failed$err") if $err || $?; } else { $self->folder_missing("$ifmt:$input"); } |