about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiMailSync.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-21 07:41:51 +0000
committerEric Wong <e@80x24.org>2021-09-21 19:18:35 +0000
commit387f0e693f9e22a7698927bb40dab0742738e8a6 (patch)
tree19a52cf42c123cbd660e2dc14a3e2b0b22dca8c5 /lib/PublicInbox/LeiMailSync.pm
parent8eaa877179910dce156179e9025d1e0df34089d8 (diff)
downloadpublic-inbox-387f0e693f9e22a7698927bb40dab0742738e8a6.tar.gz
We can set opt->{quiet} for (internal) 'note-event' command
to quiet ->qerr, since we use ->qerr everywhere else.  And
we'll just die() instead of setting a ->{fail} message, since
eval + die are more inline with the rest of our Perl code.
Diffstat (limited to 'lib/PublicInbox/LeiMailSync.pm')
-rw-r--r--lib/PublicInbox/LeiMailSync.pm17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm
index 3e725d30..f83c7de2 100644
--- a/lib/PublicInbox/LeiMailSync.pm
+++ b/lib/PublicInbox/LeiMailSync.pm
@@ -437,7 +437,7 @@ sub arg2folder {
         my ($self, $lei, $folders) = @_;
         my @all = $self->folders;
         my %all = map { $_ => 1 } @all;
-        my ($err, @no);
+        my @no;
         for (@$folders) {
                 next if $all{$_}; # ok
                 if (m!\A(maildir|mh):(.+)!i) {
@@ -454,7 +454,7 @@ sub arg2folder {
                         my $res = match_imap_url($self, $orig, \@all);
                         if (ref $res) {
                                 $_ = $$res;
-                                push(@{$err->{qerr}}, <<EOM);
+                                $lei->qerr(<<EOM);
 # using `$res' instead of `$orig'
 EOM
                         } else {
@@ -466,7 +466,7 @@ EOM
                         my $res = match_nntp_url($self, $orig, \@all);
                         if (ref $res) {
                                 $_ = $$res;
-                                push(@{$err->{qerr}}, <<EOM);
+                                $lei->qerr(<<EOM);
 # using `$res' instead of `$orig'
 EOM
                         } else {
@@ -479,12 +479,11 @@ EOM
         }
         if (@no) {
                 my $no = join("\n\t", @no);
-                $err->{fail} = <<EOF;
+                die <<EOF;
 No sync information for: $no
 Run `lei ls-mail-sync' to display valid choices
 EOF
         }
-        $err;
 }
 
 sub forget_folders {
@@ -549,12 +548,8 @@ sub imap_oidhex {
         my $mailbox_uri = $uid_uri->clone;
         $mailbox_uri->uid(undef);
         my $folders = [ $$mailbox_uri ];
-        if (my $err = $self->arg2folder($lei, $folders)) {
-                if ($err->{fail}) {
-                        $lei->qerr("# no sync information for $mailbox_uri");
-                }
-                $lei->qerr(@{$err->{qerr}}) if $err->{qerr};
-        }
+        eval { $self->arg2folder($lei, $folders) };
+        $lei->qerr("# no sync information for $mailbox_uri") if $@;
         map { unpack('H*',$_) } num_oidbin($self, $folders->[0], $uid_uri->uid)
 }