]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
overidx: use croak/confess instead of die
authorEric Wong <e@80x24.org>
Sun, 8 Oct 2023 20:19:40 +0000 (20:19 +0000)
committerEric Wong <e@80x24.org>
Sun, 8 Oct 2023 23:45:30 +0000 (23:45 +0000)
Unlike `die', `croak' can be expanded to `confess' to give a
full backtrace.  We'll use `confess' on transaction failures
since that occasionally causes sporadic t/imapd.t failures on
FreeBSD (IO::Kqueue is installed, so signals are deferred).

lib/PublicInbox/OverIdx.pm

index 5cea37068d48e29a121f6b0552df916f5160b780..aead375a31d5f3aff58ce80a47ce88bce583aeef 100644 (file)
@@ -199,7 +199,7 @@ sub resolve_mid_to_tid {
        $tid // do { # create a new ghost
                my $id = mid2id($self, $mid);
                my $num = next_ghost_num($self);
-               $num < 0 or die "ghost num is non-negative: $num\n";
+               $num < 0 or croak "BUG: ghost num is non-negative: $num\n";
                $tid = next_tid($self);
                my $dbh = $self->{dbh};
                $dbh->prepare_cached(<<'')->execute($num, $tid);
@@ -283,7 +283,7 @@ sub _add_over {
        my ($self, $smsg, $mid, $refs, $old_tid, $v) = @_;
        my $cur_tid = $smsg->{tid};
        my $n = $smsg->{num};
-       die "num must not be zero for $mid" if !$n;
+       croak "BUG: num must not be zero for $mid" if !$n;
        my $cur_valid = $cur_tid > $self->{min_tid};
 
        if ($n > 0) { # regular mail
@@ -454,7 +454,7 @@ sub rollback_lazy {
 
 sub dbh_close {
        my ($self) = @_;
-       die "in transaction" if $self->{txn};
+       Carp::confess('BUG: in transaction') if $self->{txn};
        $self->SUPER::dbh_close;
 }