Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert Exception Class renames #4272

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,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 @@ -21,7 +21,7 @@ interface Result extends DriverResult
*
* @return Traversable<int,array<int,mixed>>
*
* @throws Exception
* @throws DBALException
*/
public function iterateNumeric(): Traversable;

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

Expand All @@ -39,7 +39,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 @@ -21,6 +21,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 @@ -176,7 +177,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 @@ -194,7 +195,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 @@ -322,7 +323,7 @@ public function getEventManager()
*
* @return AbstractPlatform
*
* @throws Exception
* @throws DBALException
*/
public function getDatabasePlatform()
{
Expand Down Expand Up @@ -380,7 +381,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 @@ -407,7 +408,7 @@ private function detectDatabasePlatform(): void
*
* @return string|null
*
* @throws Throwable
* @throws Exception
*/
private function getDatabasePlatformVersion()
{
Expand Down Expand Up @@ -551,7 +552,7 @@ public function setFetchMode($fetchMode)
*
* @return array<string, 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 @@ -588,7 +589,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 @@ -605,7 +606,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 @@ -632,7 +633,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 @@ -659,7 +660,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 @@ -704,7 +705,7 @@ public function isTransactionActive()
* @param mixed[] $values Column values
* @param string[] $conditions Key conditions
*
* @throws Exception
* @throws DBALException
*/
private function addCriteriaCondition(
array $criteria,
Expand Down Expand Up @@ -737,7 +738,8 @@ private function addCriteriaCondition(
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
* @throws InvalidArgumentException
*/
public function delete($table, array $criteria, array $types = [])
{
Expand Down Expand Up @@ -806,7 +808,7 @@ public function getTransactionIsolation()
*
* @return int The number of affected rows.
*
* @throws Exception
* @throws DBALException
*/
public function update($table, array $data, array $criteria, array $types = [])
{
Expand Down Expand Up @@ -841,7 +843,7 @@ public function update($table, array $data, array $criteria, 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 @@ -944,7 +946,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 @@ -970,7 +972,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 Down Expand Up @@ -1049,7 +1051,7 @@ public function fetchAllAssociativeIndexed(string $query, array $params = [], ar
*
* @return array<int,mixed>
*
* @throws Exception
* @throws DBALException
*/
public function fetchFirstColumn(string $query, array $params = [], array $types = []): array
{
Expand All @@ -1075,7 +1077,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 @@ -1104,7 +1106,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 @@ -1177,7 +1179,7 @@ public function iterateAssociativeIndexed(string $query, array $params = [], arr
*
* @return Traversable<int,mixed>
*
* @throws Exception
* @throws DBALException
*/
public function iterateColumn(string $query, array $params = [], array $types = []): Traversable
{
Expand All @@ -1203,7 +1205,7 @@ public function iterateColumn(string $query, array $params = [], array $types =
*
* @return Statement The prepared statement.
*
* @throws Exception
* @throws DBALException
*/
public function prepare($sql)
{
Expand All @@ -1230,7 +1232,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 @@ -1363,7 +1365,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 @@ -1405,7 +1407,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 @@ -1430,7 +1432,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 @@ -1483,7 +1485,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 @@ -1568,6 +1570,7 @@ public function lastInsertId($name = null)
*
* @return mixed The value returned by $func
*
* @throws Exception
* @throws Throwable
*/
public function transactional(Closure $func)
Expand All @@ -1578,6 +1581,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 @@ -2107,14 +2114,14 @@ public function ping()
* @param array<int, mixed>|array<string, mixed> $params
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $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 @@ -2126,14 +2133,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 @@ -2143,11 +2150,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