Skip Menu |

This queue is for tickets about the Net-SSH2 CPAN distribution.

Report information
The Basics
Id: 48438
Status: resolved
Priority: 0/
Queue: Net-SSH2

People
Owner: Nobody in particular
Requestors: markusvuori [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.19
Fixed in: (no value)



Subject: Module dies if connect fails
This does NOT work: $ssh2->connect( $host ) or die "Connection cannot be established"; because the die never occurs. Reason: Connect method does not return anything, it just dies (because there's a croak call in the code). Croak should be replaced with 'return undef' or something else, which returns something and let's the calling procedure to catch the error.
Catch it with eval.
Subject: Re: [rt.cpan.org #48438] Module dies if connect fails
Date: Wed, 5 Aug 2009 13:08:57 +0300
To: bug-Net-SSH2 [...] rt.cpan.org
From: Markus Vuori <markusvuori [...] gmail.com>
Yes, it can be cought with eval. However, it would be nice if the example codes which make use of "connect or die" would work as intended. Regards, MarkusV 2009/8/5 David Robins via RT <bug-Net-SSH2@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=48438 > > > Catch it with eval. >
On Wed Aug 05 06:09:39 2009, markus@vuoret.net wrote: Show quoted text
> Yes, it can be cought with eval. However, it would be nice if the > example codes which make use of "connect or die" would work as > intended.
In 0.22, this will do what you expect: $ssh->connect(...) or die $!; In void context, it will continue to throw an exception: $ssh->connect(...); # <-- this throws exception -- Rafael