Skip to content

Commit

Permalink
Revert "Merge pull request doctrine#4253 from morozov/deprecate-dbal-…
Browse files Browse the repository at this point in the history
…exception"

This reverts commit f97ee94, reversing
changes made to f69c990.
  • Loading branch information
beberlei committed Oct 17, 2020
1 parent cce615a commit 4f73873
Show file tree
Hide file tree
Showing 55 changed files with 392 additions and 365 deletions.
4 changes: 0 additions & 4 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ The non-interface methods of driver-level classes have been marked internal:
- `OCI8Connection::getExecuteMode()`
- `OCI8Statement::convertPositionalToNamedPlaceholders()`

## Deprecated `DBALException`

The `Doctrine\DBAL\DBALException` class has been deprecated in favor of `Doctrine\DBAL\Exception`.

## Inconsistently and ambiguously named driver-level classes are deprecated

The following classes under the `Driver` namespace have been deprecated in favor of their consistently named counterparts:
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/DBAL/Abstraction/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Doctrine\DBAL\Abstraction;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Exception;
use Traversable;

/**
Expand All @@ -19,7 +19,7 @@ interface Result extends DriverResult
*
* @return Traversable<int,array<int,mixed>>
*
* @throws Exception
* @throws DBALException
*/
public function iterateNumeric(): Traversable;

Expand All @@ -28,7 +28,7 @@ public function iterateNumeric(): Traversable;
*
* @return Traversable<int,array<string,mixed>>
*
* @throws Exception
* @throws DBALException
*/
public function iterateAssociative(): Traversable;

Expand All @@ -37,7 +37,7 @@ public function iterateAssociative(): Traversable;
*
* @return Traversable<int,mixed>
*
* @throws Exception
* @throws DBALException
*/
public function iterateColumn(): Traversable;
}
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Cache/CacheException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Doctrine\DBAL\Cache;

use Doctrine\DBAL\Exception;
use Doctrine\DBAL\DBALException;

/**
* @psalm-immutable
*/
class CacheException extends Exception
class CacheException extends DBALException
{
/**
* @return CacheException
Expand Down
71 changes: 39 additions & 32 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Types\Type;
use Exception;
use Throwable;
use Traversable;

Expand Down Expand Up @@ -174,7 +175,7 @@ class Connection implements DriverConnection
* @param Configuration|null $config The configuration, optional.
* @param EventManager|null $eventManager The event manager, optional.
*
* @throws Exception
* @throws DBALException
*/
public function __construct(
array $params,
Expand All @@ -192,7 +193,7 @@ public function __construct(

if (isset($params['platform'])) {
if (! $params['platform'] instanceof Platforms\AbstractPlatform) {
throw Exception::invalidPlatformType($params['platform']);
throw DBALException::invalidPlatformType($params['platform']);
}

$this->platform = $params['platform'];
Expand Down Expand Up @@ -320,7 +321,7 @@ public function getEventManager()
*
* @return AbstractPlatform
*
* @throws Exception
* @throws DBALException
*/
public function getDatabasePlatform()
{
Expand Down Expand Up @@ -378,7 +379,7 @@ public function connect()
*
* Evaluates custom platform class and version in order to set the correct platform.
*
* @throws Exception If an invalid platform was specified for this connection.
* @throws DBALException If an invalid platform was specified for this connection.
*/
private function detectDatabasePlatform(): void
{
Expand All @@ -405,7 +406,7 @@ private function detectDatabasePlatform(): void
*
* @return string|null
*
* @throws Throwable
* @throws Exception
*/
private function getDatabasePlatformVersion()
{
Expand Down Expand Up @@ -549,7 +550,7 @@ public function setFetchMode($fetchMode)
*
* @return mixed[]|false False is returned if no rows are found.
*
* @throws Exception
* @throws DBALException
*/
public function fetchAssoc($sql, array $params = [], array $types = [])
{
Expand Down Expand Up @@ -586,7 +587,7 @@ public function fetchArray($sql, array $params = [], array $types = [])
*
* @return mixed|false False is returned if no rows are found.
*
* @throws Exception
* @throws DBALException
*/
public function fetchColumn($sql, array $params = [], $column = 0, array $types = [])
{
Expand All @@ -603,7 +604,7 @@ public function fetchColumn($sql, array $params = [], $column = 0, array $types
*
* @return array<string, mixed>|false False is returned if no rows are found.
*
* @throws Exception
* @throws DBALException
*/
public function fetchAssociative(string $query, array $params = [], array $types = [])
{
Expand All @@ -630,7 +631,7 @@ public function fetchAssociative(string $query, array $params = [], array $types
*
* @return array<int, mixed>|false False is returned if no rows are found.
*
* @throws Exception
* @throws DBALException
*/
public function fetchNumeric(string $query, array $params = [], array $types = [])
{
Expand All @@ -657,7 +658,7 @@ public function fetchNumeric(string $query, array $params = [], array $types = [
*
* @return mixed|false False is returned if no rows are found.
*
* @throws Exception
* @throws DBALException
*/
public function fetchOne(string $query, array $params = [], array $types = [])
{
Expand Down Expand Up @@ -702,7 +703,7 @@ public function isTransactionActive()
* @param mixed[] $values Column values
* @param string[] $conditions Key conditions
*
* @throws Exception
* @throws DBALException
*/
private function addIdentifierCondition(
array $identifier,
Expand Down Expand Up @@ -735,7 +736,8 @@ private function addIdentifierCondition(
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
* @throws InvalidArgumentException
*/
public function delete($table, array $identifier, array $types = [])
{
Expand Down Expand Up @@ -804,7 +806,7 @@ public function getTransactionIsolation()
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
*/
public function update($table, array $data, array $identifier, array $types = [])
{
Expand Down Expand Up @@ -839,7 +841,7 @@ public function update($table, array $data, array $identifier, array $types = []
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
*/
public function insert($table, array $data, array $types = [])
{
Expand Down Expand Up @@ -940,7 +942,7 @@ public function fetchAll($sql, array $params = [], $types = [])
*
* @return array<int,array<int,mixed>>
*
* @throws Exception
* @throws DBALException
*/
public function fetchAllNumeric(string $query, array $params = [], array $types = []): array
{
Expand All @@ -966,7 +968,7 @@ public function fetchAllNumeric(string $query, array $params = [], array $types
*
* @return array<int,array<string,mixed>>
*
* @throws Exception
* @throws DBALException
*/
public function fetchAllAssociative(string $query, array $params = [], array $types = []): array
{
Expand All @@ -992,7 +994,7 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty
*
* @return array<int,mixed>
*
* @throws Exception
* @throws DBALException
*/
public function fetchFirstColumn(string $query, array $params = [], array $types = []): array
{
Expand All @@ -1018,7 +1020,7 @@ public function fetchFirstColumn(string $query, array $params = [], array $types
*
* @return Traversable<int,array<int,mixed>>
*
* @throws Exception
* @throws DBALException
*/
public function iterateNumeric(string $query, array $params = [], array $types = []): Traversable
{
Expand Down Expand Up @@ -1047,7 +1049,7 @@ public function iterateNumeric(string $query, array $params = [], array $types =
*
* @return Traversable<int,array<string,mixed>>
*
* @throws Exception
* @throws DBALException
*/
public function iterateAssociative(string $query, array $params = [], array $types = []): Traversable
{
Expand Down Expand Up @@ -1075,7 +1077,7 @@ public function iterateAssociative(string $query, array $params = [], array $typ
*
* @return Traversable<int,mixed>
*
* @throws Exception
* @throws DBALException
*/
public function iterateColumn(string $query, array $params = [], array $types = []): Traversable
{
Expand All @@ -1101,7 +1103,7 @@ public function iterateColumn(string $query, array $params = [], array $types =
*
* @return Statement The prepared statement.
*
* @throws Exception
* @throws DBALException
*/
public function prepare($sql)
{
Expand Down Expand Up @@ -1129,7 +1131,7 @@ public function prepare($sql)
*
* @return ResultStatement The executed statement.
*
* @throws Exception
* @throws DBALException
*/
public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null)
{
Expand Down Expand Up @@ -1263,7 +1265,7 @@ public function project($sql, array $params, Closure $function)
*
* @return \Doctrine\DBAL\Driver\Statement
*
* @throws Exception
* @throws DBALException
*/
public function query()
{
Expand Down Expand Up @@ -1305,7 +1307,7 @@ public function query()
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
*/
public function executeUpdate($sql, array $params = [], array $types = [])
{
Expand All @@ -1330,7 +1332,7 @@ public function executeUpdate($sql, array $params = [], array $types = [])
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
*/
public function executeStatement($sql, array $params = [], array $types = [])
{
Expand Down Expand Up @@ -1383,7 +1385,7 @@ public function executeStatement($sql, array $params = [], array $types = [])
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
*/
public function exec($sql)
{
Expand Down Expand Up @@ -1468,6 +1470,7 @@ public function lastInsertId($name = null)
*
* @return mixed The value returned by $func
*
* @throws Exception
* @throws Throwable
*/
public function transactional(Closure $func)
Expand All @@ -1478,6 +1481,10 @@ public function transactional(Closure $func)
$this->commit();

return $res;
} catch (Exception $e) {
$this->rollBack();

throw $e;
} catch (Throwable $e) {
$this->rollBack();

Expand Down Expand Up @@ -2007,14 +2014,14 @@ public function ping()
* @param array<int, mixed>|array<string, mixed> $params
* @param array<int, int|string>|array<string, int|string> $types
*
* @throws Exception
* @throws DBALException
*
* @psalm-return never-return
*/
public function handleExceptionDuringQuery(Throwable $e, string $sql, array $params = [], array $types = []): void
{
$this->throw(
Exception::driverExceptionDuringQuery(
DBALException::driverExceptionDuringQuery(
$this->_driver,
$e,
$sql,
Expand All @@ -2026,14 +2033,14 @@ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $par
/**
* @internal
*
* @throws Exception
* @throws DBALException
*
* @psalm-return never-return
*/
public function handleDriverException(Throwable $e): void
{
$this->throw(
Exception::driverException(
DBALException::driverException(
$this->_driver,
$e
)
Expand All @@ -2043,11 +2050,11 @@ public function handleDriverException(Throwable $e): void
/**
* @internal
*
* @throws Exception
* @throws DBALException
*
* @psalm-return never-return
*/
private function throw(Exception $e): void
private function throw(DBALException $e): void
{
if ($e instanceof ConnectionLost) {
$this->close();
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/ConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @psalm-immutable
*/
class ConnectionException extends Exception
class ConnectionException extends DBALException
{
/**
* @return ConnectionException
Expand Down
Loading

0 comments on commit 4f73873

Please sign in to comment.