Skip to content

Commit 2eae437

Browse files
authored
Merge pull request #245 from keboola/zajca/fix-odbc-connection-returning-fail
2 parents cf79bed + 665d59c commit 2eae437

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/Connection/Snowflake/SnowflakeConnection.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@ public function __construct(
2828
) {
2929
try {
3030
$handle = odbc_connect($dsn, $user, $password);
31-
assert($handle !== false);
31+
if ($handle === false) {
32+
$code = odbc_error() ?: '0';
33+
$message = odbc_errormsg() ?: 'ODBC connection failed';
34+
throw DriverException::newConnectionFailure($message, (int) $code, null);
35+
}
3236
$this->conn = $handle;
37+
} catch (DriverException $e) {
38+
// only rethrow our exception
39+
throw $e;
3340
} catch (Throwable $e) {
3441
throw DriverException::newConnectionFailure($e->getMessage(), (int) $e->getCode(), $e->getPrevious());
3542
}
36-
3743
if (isset($options['runId'])) {
3844
$queryTag = [
3945
'runId' => $options['runId'],

0 commit comments

Comments
 (0)