Skip to content

Commit

Permalink
Merge pull request #134 from zoonru/add_new_exception
Browse files Browse the repository at this point in the history
Enhancement: Add a new exception to be able to distinguish that ClickHouse is not available.
  • Loading branch information
isublimity authored Feb 3, 2020
2 parents 2e6852c + 7b583b5 commit bbcc62f
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 bbcc62f

Please sign in to comment.