Skip to content

Commit

Permalink
Prettier "Can't connect" message in response
Browse files Browse the repository at this point in the history
  • Loading branch information
gisle committed Feb 13, 2011
1 parent 20563d0 commit 04810a0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/LWP/Protocol/http.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ sub _new_socket

unless ($sock) {
# IO::Socket::INET leaves additional error messages in $@
$@ =~ s/^.*?: //;
die "Can't connect to $host:$port ($@)";
my $status = "Can't connect to $host:$port";
if ($@ =~ /\bconnect: (.*)/ ||
$@ =~ /\b(Bad hostname)\b/ ||
$@ =~ /\b(certificate verify failed)\b/
) {
$status .= " ($1)";
}
die "$status\n\n$@";
}

# perl 5.005's IO::Socket does not have the blocking method.
Expand Down

0 comments on commit 04810a0

Please sign in to comment.