Skip to content

Commit

Permalink
Adds a new exception to be able to distinguish that ClickHouse is not…
Browse files Browse the repository at this point in the history
… available.
  • Loading branch information
atimur committed Jan 31, 2020
1 parent 2e6852c commit 7b583b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Exception/ClickHouseUnavailableException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

declare(strict_types=1);

namespace ClickHouseDB\Exception;

final class ClickHouseUnavailableException extends QueryException {
}
4 changes: 4 additions & 0 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ClickHouseDB;

use ClickHouseDB\Exception\ClickHouseUnavailableException;
use ClickHouseDB\Exception\DatabaseException;
use ClickHouseDB\Exception\QueryException;
use ClickHouseDB\Query\Query;
Expand Down Expand Up @@ -176,6 +177,9 @@ public function error()
$message = $this->response()->error();
}

if ($code === CURLE_COULDNT_CONNECT) {
throw new ClickHouseUnavailableException($message, $code);
}
throw new QueryException($message, $code);
}

Expand Down

0 comments on commit 7b583b5

Please sign in to comment.