Skip to content

Commit

Permalink
Check if FTP connection succeeded
Browse files Browse the repository at this point in the history
ftp_connect can trigger a warning when not successful.
In that case no ErrorException is thrown, and it was impossible to know wether the connection succeeded.
Now Throws a FtpException if no resource was returned by ftp_connect.
  • Loading branch information
RonanL authored Nov 2, 2016
1 parent 370e6d0 commit b815e22
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public function __call($name, $args)
} catch (\ErrorException $e) {
throw new FtpException($e->getMessage());
}
if (!is_resource($this->resource)) {
throw new FtpException("An error occured while trying to connect to FTP server.");
}
$result = null;

} elseif (!is_resource($this->resource)) {
Expand Down

0 comments on commit b815e22

Please sign in to comment.