Skip to content

Commit

Permalink
driver exception: sqlstate is always string
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Nov 15, 2020
1 parent e29af04 commit 0d3096b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Drivers/Exception/DriverException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class DriverException extends Exception
public function __construct(
string $message,
int $errorCode = 0,
string $errorSqlState = null,
string $errorSqlState = '',
Exception $previousException = null
)
{
parent::__construct($message, 0, $previousException);
$this->errorCode = $errorCode;
$this->errorSqlState = (string) $errorSqlState;
$this->errorSqlState = $errorSqlState;
}


Expand Down
6 changes: 3 additions & 3 deletions src/Drivers/Pgsql/PgsqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ protected function createException(string $error, int $errorNo, ?string $sqlStat
return new UniqueConstraintViolationException($error, $errorNo, $sqlState, null, $query);

} elseif ($sqlState === null && stripos($error, 'pg_connect()') !== false) {
return new ConnectionException($error, $errorNo, $sqlState);
return new ConnectionException($error, $errorNo, '');

} elseif ($query !== null) {
return new QueryException($error, $errorNo, (string) $sqlState, null, $query);
return new QueryException($error, $errorNo, $sqlState ?? '', null, $query);

} else {
return new DriverException($error, $errorNo, $sqlState);
return new DriverException($error, $errorNo, $sqlState ?? '');
}
}

Expand Down

0 comments on commit 0d3096b

Please sign in to comment.