Merge pull request #22 from utopia-php/feat-connection-failure-error

Add error handling for MongoDB connection failure in Client class
This commit is contained in:
Jake Barnby authored and GitHub committed 2025-08-04 21:49:58 +12:00
commit 1c9853166a
1 file changed
+3 -1
+3 -1
View File
@@ -118,8 +118,10 @@ class Client
if ($this->client->isConnected()) {
return $this;
}
if (!$this->client->connect($this->host, $this->port)) {
throw new Exception("Failed to connect to MongoDB at {$this->host}:{$this->port}");
}
$this->client->connect($this->host, $this->port);
[$payload, $db] = $this->auth->start();
$res = $this->query($payload, $db);