unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/3] lei+net_reader: show NNTP message in more failures
Date: Wed, 10 Jan 2024 11:18:54 +0000	[thread overview]
Message-ID: <20240110111855.2656443-3-e@80x24.org> (raw)
In-Reply-To: <20240110111855.2656443-1-e@80x24.org>

Showing absolutely nothing when hitting a server requiring
authentication is a very bad user experience.  While we're
at it, use Net::Cmd->message in more places where we experience
failure, too.
---
 lib/PublicInbox/LeiLsMailSource.pm |  6 +++++-
 lib/PublicInbox/NetReader.pm       | 19 +++++++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/LeiLsMailSource.pm b/lib/PublicInbox/LeiLsMailSource.pm
index 4b427b26..ab6c1e60 100644
--- a/lib/PublicInbox/LeiLsMailSource.pm
+++ b/lib/PublicInbox/LeiLsMailSource.pm
@@ -42,7 +42,11 @@ sub input_path_url { # overrides LeiInput version
 		my $uri = PublicInbox::URInntps->new($url);
 		my $nn = $lei->{net}->nn_get($uri) or
 			return $lei->err("E: $uri");
-		my $l = $nn->newsgroups($uri->group); # name => description
+		# $l = name => description
+		my $l = $nn->newsgroups($uri->group) // return $lei->err(<<EOM);
+E: $uri LIST NEWSGROUPS: ${\($lei->{net}->ndump($nn->message))}
+E: login may be required, try adding `-c nntp.debug' to your command
+EOM
 		my $sec = $lei->{net}->can('uri_section')->($uri);
 		if ($json) {
 			my $all = $nn->list;
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index 751043e9..ec18818b 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -14,7 +14,7 @@ our @EXPORT = qw(uri_section imap_uri nntp_uri);
 
 sub ndump {
 	require Data::Dumper;
-	Data::Dumper->new(\@_)->Useqq(1)->Terse(1)->Dump;
+	Data::Dumper->new([ $_[-1] ])->Useqq(1)->Terse(1)->Dump;
 }
 
 # returns the git config section name, e.g [imap "imaps://user@example.com"]
@@ -240,19 +240,19 @@ sub nn_new ($$$$) {
 				try_starttls($nn_arg->{Host})) {
 			# soft fail by default
 			$nn->starttls or warn <<"";
-W: <$uri> STARTTLS tried and failed (not requested)
+W: <$uri> STARTTLS tried and failed (not requested): ${\(ndump($nn->message))}
 
 		} elsif ($nntp_cfg->{starttls}) {
 			# hard fail if explicitly configured
 			$nn->starttls or die <<"";
-E: <$uri> STARTTLS requested and failed
+E: <$uri> STARTTLS requested and failed: ${\(ndump($nn->message))}
 
 		}
 	} elsif ($nntp_cfg->{starttls}) {
 		$nn->can('starttls') or
 			die "E: <$uri> Net::NNTP too old for STARTTLS\n";
 		$nn->starttls or die <<"";
-E: <$uri> STARTTLS requested and failed
+E: <$uri> STARTTLS requested and failed: ${\(ndump($nn->message))}
 
 	}
 	$nn;
@@ -298,18 +298,21 @@ sub nn_for ($$$$) { # nn = Net::NNTP
 		if ($nn->authinfo($u, $p)) {
 			push @{$nntp_cfg->{-postconn}}, [ 'authinfo', $u, $p ];
 		} else {
-			warn "E: <$uri> AUTHINFO $u XXXX failed\n";
+			warn <<EOM;
+E: <$uri> AUTHINFO $u XXXX: ${\(ndump($nn->message))}
+EOM
 			$nn = undef;
 		}
 	}
-
-	if ($nntp_cfg->{compress}) {
+	if ($nn && $nntp_cfg->{compress}) {
 		# https://rt.cpan.org/Ticket/Display.html?id=129967
 		if ($nn->can('compress')) {
 			if ($nn->compress) {
 				push @{$nntp_cfg->{-postconn}}, [ 'compress' ];
 			} else {
-				warn "W: <$uri> COMPRESS failed\n";
+				warn <<EOM;
+W: <$uri> COMPRESS: ${\(ndump($nn->message))}
+EOM
 			}
 		} else {
 			delete $nntp_cfg->{compress};

  parent reply	other threads:[~2024-01-10 11:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 11:18 [PATCH 0/3] lei NNTP + error handling fixes Eric Wong
2024-01-10 11:18 ` [PATCH 1/3] net_reader: fix NNTP credential use Eric Wong
2024-01-10 11:18 ` Eric Wong [this message]
2024-01-10 11:18 ` [PATCH 3/3] lei_to_mail: show supported mbox formats on error Eric Wong

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=20240110111855.2656443-3-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.
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).