]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
search: async_mset: always run callback on exceptions
authorEric Wong <e@80x24.org>
Tue, 11 Feb 2025 03:55:34 +0000 (03:55 +0000)
committerEric Wong <e@80x24.org>
Tue, 11 Feb 2025 19:08:15 +0000 (19:08 +0000)
To produce consistent error behavior, ensure we always run
the user-supplied callback on exceptions when using in-process
Xapian (as opposed to the external xap_helper process).

lib/PublicInbox/Search.pm

index 784e3b0a4daad14f925a9f8c462b542bb17963a2..cb1661016ec07d64268488513f122d98d6155a54 100644 (file)
@@ -493,8 +493,8 @@ sub async_mset {
                $cb->(@args, undef, $@) if $@;
                $ret;
        } else { # synchronous
-               my $mset = $self->mset($qry_str, $opt);
-               $cb->(@args, $mset);
+               my $mset = eval { $self->mset($qry_str, $opt) };
+               $@ ? $cb->(@args, undef, $@) : $cb->(@args, $mset);
                undef;
        }
 }