Skip Menu |

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

Report information
The Basics
Id: 89209
Status: rejected
Priority: 0/
Queue: Net-SFTP-Foreign

People
Owner: Nobody in particular
Requestors: tmetro [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.75
Fixed in: (no value)



Subject: constructor returns true on failure
my $sftp = Net::SFTP::Foreign->new($host) or die "$host: connect failed\n"; will not have the expected result because your code still returns true even when the connection fails. I can see arguments in favor of this approach (i.e. making all the error handling code look consistent), but I believe it is inconsistent with how most network libraries handle their constructors. (Maybe I'm wrong. Find some examples that follow your approach.) More importantly, your documentation for new() doesn't describe this behavior, but only hints at it by saying "An explicit check for errors should be included always after the constructor call."
On Wed Oct 02 15:44:42 2013, TMETRO wrote: Show quoted text
> my $sftp = Net::SFTP::Foreign->new($host) > or die "$host: connect failed\n"; > > will not have the expected result because your code still returns true > even when the connection fails. I can see arguments in favor of this > approach (i.e. making all the error handling code look consistent), > but I believe it is inconsistent with how most network libraries > handle their constructors. (Maybe I'm wrong. Find some examples that > follow your approach.) > > More importantly, your documentation for new() doesn't describe this > behavior, but only hints at it by saying "An explicit check for errors > should be included always after the constructor call."
This is by design, in order to let the user check the error easily. In any case, it is too late to change the module API.