user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] overidx: use croak/confess instead of die
Date: Sun,  8 Oct 2023 20:19:40 +0000	[thread overview]
Message-ID: <20231008201940.21537-1-e@80x24.org> (raw)

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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 5cea3706..aead375a 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -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;
 }
 

                 reply	other threads:[~2023-10-08 20:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231008201940.21537-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).