Skip to content

Commit 9956819

Browse files
committed
Throw exception if there is a connection error
1 parent 4501c7e commit 9956819

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/SSHConnection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function connect(): self
6868

6969
$this->resource = ssh2_connect($this->hostname, $this->port);
7070

71+
if (!$this->resource) {
72+
throw new RuntimeException('Error connecting to server.');
73+
}
74+
7175
if ($this->publicKeyPath || $this->privateKeyPath) {
7276
$authenticated = ssh2_auth_pubkey_file($this->resource, $this->username, $this->publicKeyPath, $this->privateKeyPath);
7377
if (!$authenticated) {

0 commit comments

Comments
 (0)