Skip to content

Commit 7b583b5

Browse files
author
atimur
committed
Adds a new exception to be able to distinguish that ClickHouse is not available.
1 parent 2e6852c commit 7b583b5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ClickHouseDB\Exception;
6+
7+
final class ClickHouseUnavailableException extends QueryException {
8+
}

src/Statement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ClickHouseDB;
44

5+
use ClickHouseDB\Exception\ClickHouseUnavailableException;
56
use ClickHouseDB\Exception\DatabaseException;
67
use ClickHouseDB\Exception\QueryException;
78
use ClickHouseDB\Query\Query;
@@ -176,6 +177,9 @@ public function error()
176177
$message = $this->response()->error();
177178
}
178179

180+
if ($code === CURLE_COULDNT_CONNECT) {
181+
throw new ClickHouseUnavailableException($message, $code);
182+
}
179183
throw new QueryException($message, $code);
180184
}
181185

0 commit comments

Comments
 (0)