From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EF0A01F87C for ; Thu, 9 Nov 2023 10:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1699524588; bh=acBKXI1WzDiz/m3dq4TBhZ3QAcgfwDKMbIX54frDmr4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=45wYXCnCL2oY7+WaIoEuqRdw/VG1SzmA9nfWT8ONIIc9UAEvXmrZDm38EncJDlvbt kJUU0TvhnzaSdRmsPE3i+NIiY0YSS7KKTko80YSKiAR5k7n3yzQVqE6RHH82JZmM8b EO8nvaULvV2G/RAOcC6Uo6mofGw/0QTg8jpF8R/s= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/13] lei ls-mail-source: gracefully handle network failures Date: Thu, 9 Nov 2023 10:09:39 +0000 Message-ID: <20231109100946.1440611-7-e@80x24.org> In-Reply-To: <20231109100946.1440611-1-e@80x24.org> References: <20231109100946.1440611-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: All network connections may fail, so try to emit a helpful error message instead of attempting to dispatch methods off `undef'. --- lib/PublicInbox/LeiLsMailSource.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiLsMailSource.pm b/lib/PublicInbox/LeiLsMailSource.pm index 50799270..4b427b26 100644 --- a/lib/PublicInbox/LeiLsMailSource.pm +++ b/lib/PublicInbox/LeiLsMailSource.pm @@ -19,7 +19,8 @@ sub input_path_url { # overrides LeiInput version if ($url =~ m!\Aimaps?://!i) { my $uri = PublicInbox::URIimap->new($url); my $sec = $lei->{net}->can('uri_section')->($uri); - my $mic = $lei->{net}->mic_get($uri); + my $mic = $lei->{net}->mic_get($uri) or + return $lei->err("E: $uri"); my $l = $mic->folders_hash($uri->path); # server-side filter @$l = map { $_->[2] } # undo Schwartzian transform below: sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] } @@ -39,7 +40,8 @@ sub input_path_url { # overrides LeiInput version } } elsif ($url =~ m!\A(?:nntps?|s?news)://!i) { my $uri = PublicInbox::URInntps->new($url); - my $nn = $lei->{net}->nn_get($uri); + my $nn = $lei->{net}->nn_get($uri) or + return $lei->err("E: $uri"); my $l = $nn->newsgroups($uri->group); # name => description my $sec = $lei->{net}->can('uri_section')->($uri); if ($json) {