Skip to content

Commit f3e77ee

Browse files
authored
Add the exception code and the previous throwable
Add the exception code and the previous throwable when re-throw exceptions
1 parent f77df0d commit f3e77ee

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Drivers/Pdo/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function query($query)
2525
try {
2626
$statement->execute();
2727
} catch (PDOException $exception) {
28-
throw new DatabaseException($exception->getMessage() . ' [' . $query . ']');
28+
throw new DatabaseException($exception->getMessage() . ' [' . $query . ']', $exception->getCode(), $exception);
2929
}
3030

3131
return new ResultSet(new ResultSetAdapter($statement));
@@ -56,7 +56,7 @@ public function connect()
5656
try {
5757
$con = new PDO($dsn);
5858
} catch (PDOException $exception) {
59-
throw new ConnectionException($exception->getMessage());
59+
throw new ConnectionException($exception->getMessage(), $exception->getCode(), $exception);
6060
}
6161

6262
$this->connection = $con;
@@ -90,7 +90,7 @@ public function multiQuery(array $queue)
9090
try {
9191
$statement = $this->connection->query(implode(';', $queue));
9292
} catch (PDOException $exception) {
93-
throw new DatabaseException($exception->getMessage() .' [ '.implode(';', $queue).']');
93+
throw new DatabaseException($exception->getMessage() .' [ '.implode(';', $queue).']', $exception->getCode(), $exception);
9494
}
9595

9696
return new MultiResultSet(new MultiResultSetAdapter($statement));

0 commit comments

Comments
 (0)