Commit b9131de6 authored by Crell's avatar Crell

Clean up exception naming with a new interface.

parent 49839784
......@@ -75,7 +75,7 @@ abstract class Connection extends PDO {
*
* @var string
*/
protected $statementClass = 'Drupal\Core\Database\StatementBase';
protected $statementClass = 'Drupal\Core\Database\Statement';
/**
* Whether this database connection supports transactions.
......
<?php
/**
* @file
* Definition of Drupal\Core\Database\DatabaseException
*/
namespace Drupal\Core\Database;
/**
* Interface for a database exception.
*
* All Database exceptions should implement this interface so that they can be
* caught collectively. Note that this applies only to Drupal-spawned
* exceptions. PDOException will not implement this interface and module
* developers should account for it separately.
*/
interface DatabaseException { }
......@@ -7,7 +7,9 @@
namespace Drupal\Core\Database\Query;
use RuntimeException;
use Drupal\Core\Database\DatabaseException;
use InvalidArgumentException;
/**
* Exception thrown if an insert query specifies a field twice.
......@@ -15,4 +17,4 @@
* It is not allowed to specify a field as default and insert field, this
* exception is thrown if that is the case.
*/
class FieldsOverlapException extends RuntimeException {}
class FieldsOverlapException extends InvalidArgumentException implements DatabaseException {}
......@@ -7,7 +7,9 @@
namespace Drupal\Core\Database\Query;
use RuntimeException;
use Drupal\Core\Database\DatabaseException;
use InvalidArgumentException;
/**
* Exception thrown for merge queries that do not make semantic sense.
......@@ -15,4 +17,4 @@
* There are many ways that a merge query could be malformed. They should all
* throw this exception and set an appropriately descriptive message.
*/
class InvalidMergeQueryException extends RuntimeException {}
class InvalidMergeQueryException extends InvalidArgumentException implements DatabaseException {}
......@@ -7,9 +7,11 @@
namespace Drupal\Core\Database\Query;
use Exception;
use Drupal\Core\Database\DatabaseException;
use InvalidArgumentException;
/**
* Exception thrown if an insert query doesn't specify insert or default fields.
*/
class NoFieldsException extends Exception {}
class NoFieldsException extends InvalidArgumentException implements DatabaseException {}
......@@ -12,4 +12,4 @@
/**
* Base exception for Schema-related errors.
*/
class SchemaException extends RuntimeException {}
class SchemaException extends RuntimeException implements DatabaseException { }
......@@ -14,4 +14,4 @@
* modify a database table, field, or index that does not currently exist in
* the database schema.
*/
class SchemaObjectDoesNotExistException extends SchemaException {}
class SchemaObjectDoesNotExistException extends SchemaException implements DatabaseException { }
......@@ -14,4 +14,4 @@
* create a new database table, field, or index that already exists in the
* database schema.
*/
class SchemaObjectExistsException extends SchemaException {}
class SchemaObjectExistsException extends SchemaException implements DatabaseException { }
......@@ -21,7 +21,7 @@
*
* @see http://us.php.net/pdostatement
*/
class StatementBase extends PDOStatement implements StatementInterface {
class Statement extends PDOStatement implements StatementInterface {
/**
* Reference to the database connection object for this statement.
......
......@@ -10,4 +10,4 @@
/**
* Exception thrown when a commit() function fails.
*/
class TransactionCommitFailedException extends TransactionException { }
class TransactionCommitFailedException extends TransactionException implements DatabaseException { }
......@@ -12,4 +12,4 @@
/**
* Exception thrown by an error in a database transaction.
*/
class TransactionException extends RuntimeException { }
class TransactionException extends RuntimeException implements DatabaseException { }
......@@ -13,4 +13,4 @@
* This exception will be thrown when the PDO connection commit() is called.
* Code should never call this method directly.
*/
class TransactionExplicitCommitNotAllowedException extends TransactionException { }
class TransactionExplicitCommitNotAllowedException extends TransactionException implements DatabaseException { }
......@@ -10,4 +10,4 @@
/**
* Exception thrown when a savepoint or transaction name occurs twice.
*/
class TransactionNameNonUniqueException extends TransactionException { }
class TransactionNameNonUniqueException extends TransactionException implements DatabaseException { }
......@@ -10,4 +10,4 @@
/**
* Exception for when popTransaction() is called with no active transaction.
*/
class TransactionNoActiveException extends TransactionException { }
class TransactionNoActiveException extends TransactionException implements DatabaseException { }
......@@ -10,4 +10,4 @@
/**
* Exception thrown when a rollback() resulted in other active transactions being rolled-back.
*/
class TransactionOutOfOrderException extends TransactionException { }
class TransactionOutOfOrderException extends TransactionException implements DatabaseException { }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment