[2.0] More replacing of old style of exceptions to intermediate step
This commit is contained in:
parent
5582f07b53
commit
43b6791919
51
lib/Doctrine/DBAL/ConnectionException.php
Normal file
51
lib/Doctrine/DBAL/ConnectionException.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: Exception.php 4628 2008-07-04 16:32:19Z romanb $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\Common\DoctrineException;
|
||||
|
||||
/**
|
||||
* Doctrine\DBAL\ConnectionException
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @version $Revision: 4628 $
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com
|
||||
*/
|
||||
class ConnectionException extends DoctrineException
|
||||
{
|
||||
public static function invalidPDOInstance()
|
||||
{
|
||||
return new self("Invalid PDO instance provided on connection creation.");
|
||||
}
|
||||
|
||||
public static function driverRequired()
|
||||
{
|
||||
return new self("Please provide a driver or a driverClass to be able to start a Connection.");
|
||||
}
|
||||
|
||||
public static function unknownDriver($driver)
|
||||
{
|
||||
return new self("Unknown Connection driver '$driver'.");
|
||||
}
|
||||
}
|
@ -1831,7 +1831,7 @@ abstract class AbstractPlatform
|
||||
case Connection::TRANSACTION_SERIALIZABLE:
|
||||
return 'SERIALIZABLE';
|
||||
default:
|
||||
throw new Doctrine_Common_Exceptions_DoctrineException('isolation level is not supported: ' . $isolation);
|
||||
throw \Doctrine\Common\DoctrineException::updateMe('isolation level is not supported: ' . $isolation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1842,7 +1842,7 @@ abstract class AbstractPlatform
|
||||
*/
|
||||
public function getSetTransactionIsolationSql($level)
|
||||
{
|
||||
throw new DoctrineException('Set transaction isolation not supported by this platform.');
|
||||
throw \Doctrine\Common\DoctrineException::updateMe('Set transaction isolation not supported by this platform.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ class Statement
|
||||
$this->_stmt = $stmt;
|
||||
|
||||
if ($stmt === false) {
|
||||
throw new DoctrineException('Unknown statement object given.');
|
||||
throw \Doctrine\Common\DoctrineException::updateMe('Unknown statement object given.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ abstract class Type
|
||||
}
|
||||
if ( ! isset(self::$_typeObjects[$name])) {
|
||||
if ( ! isset(self::$_typesMap[$name])) {
|
||||
throw new DoctrineException("Unknown type: $name");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Unknown type: $name");
|
||||
}
|
||||
self::$_typeObjects[$name] = new self::$_typesMap[$name]();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class ApcCache implements Cache
|
||||
public function __construct()
|
||||
{
|
||||
if ( ! extension_loaded('apc')) {
|
||||
throw new DoctrineException('The apc extension must be loaded in order to use the ApcCache.');
|
||||
\Doctrine\Common\DoctrineException::updateMe('The apc extension must be loaded in order to use the ApcCache.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ class EntityManager
|
||||
$this->_hydrators[$hydrationMode] = new \Doctrine\ORM\Internal\Hydration\NoneHydrator($this);
|
||||
break;
|
||||
default:
|
||||
throw new DoctrineException("No hydrator found for hydration mode '$hydrationMode'.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("No hydrator found for hydration mode '$hydrationMode'.");
|
||||
}
|
||||
} else if ($this->_hydrators[$hydrationMode] instanceof Closure) {
|
||||
$this->_hydrators[$hydrationMode] = $this->_hydrators[$hydrationMode]($this);
|
||||
@ -596,7 +596,7 @@ class EntityManager
|
||||
if (is_array($conn)) {
|
||||
$conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
|
||||
} else if ( ! $conn instanceof Connection) {
|
||||
throw new DoctrineException("Invalid parameter '$conn'.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Invalid parameter '$conn'.");
|
||||
}
|
||||
|
||||
if (is_null($config)) {
|
||||
|
@ -121,7 +121,7 @@ class ClassExporter
|
||||
$foreignKeyConstraints[] = $constraint;
|
||||
} else if ($mapping->isOneToMany() && $mapping->isOwningSide()) {
|
||||
//... create join table, one-many through join table supported later
|
||||
throw new DoctrineException("Not yet implemented.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Not yet implemented.");
|
||||
} else if ($mapping->isManyToMany() && $mapping->isOwningSide()) {
|
||||
//... create join table
|
||||
$joinTableColumns = array();
|
||||
|
@ -61,7 +61,7 @@ class Assigned extends AbstractIdGenerator
|
||||
}
|
||||
|
||||
if ( ! $identifier) {
|
||||
throw new DoctrineException("Entity of type '" . get_class($entity) . "' is missing an assigned ID.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Entity of type '" . get_class($entity) . "' is missing an assigned ID.");
|
||||
}
|
||||
|
||||
return $identifier;
|
||||
|
@ -12,7 +12,7 @@ class TableGenerator extends AbstractIdGenerator
|
||||
|
||||
public function generate($entity)
|
||||
{
|
||||
throw new \Exception("Not implemented");
|
||||
throw \Doctrine\Common\DoctrineException::updateMe("Not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ abstract class AbstractHydrator
|
||||
}
|
||||
}
|
||||
|
||||
throw new DoctrineException("No field name found for column name '$lcColumnName' during hydration.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("No field name found for column name '$lcColumnName' during hydration.");
|
||||
}
|
||||
|
||||
/** Needed only temporarily until the new parser is ready */
|
||||
|
@ -389,7 +389,7 @@ final class ClassMetadata
|
||||
public function getSingleIdReflectionProperty()
|
||||
{
|
||||
if ($this->_isIdentifierComposite) {
|
||||
throw new DoctrineException("getSingleIdReflectionProperty called on entity with composite key.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("getSingleIdReflectionProperty called on entity with composite key.");
|
||||
}
|
||||
return $this->_reflectionProperties[$this->_identifier[0]];
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class AnnotationDriver
|
||||
|
||||
// Evaluate DoctrineEntity annotation
|
||||
if (($entityAnnot = $annotClass->getAnnotation('DoctrineEntity')) === false) {
|
||||
throw new MappingException("$className is no entity.");
|
||||
throw \Doctrine\Common\DoctrineException::updateMe("$className is no entity.");
|
||||
}
|
||||
$metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
|
||||
|
||||
@ -109,7 +109,7 @@ class AnnotationDriver
|
||||
// DoctrineOneToOne, DoctrineOneToMany, DoctrineManyToOne, DoctrineManyToMany
|
||||
if ($columnAnnot = $property->getAnnotation('DoctrineColumn')) {
|
||||
if ($columnAnnot->type == null) {
|
||||
throw new MappingException("Missing type on property " . $property->getName());
|
||||
throw \Doctrine\Common\DoctrineException::updateMe("Missing type on property " . $property->getName());
|
||||
}
|
||||
$mapping['type'] = $columnAnnot->type;
|
||||
$mapping['length'] = $columnAnnot->length;
|
||||
|
@ -127,7 +127,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
|
||||
$this->_ownerClass = $em->getClassMetadata($type);
|
||||
if ($keyField !== null) {
|
||||
if ( ! $this->_ownerClass->hasField($keyField)) {
|
||||
throw new DoctrineException("Invalid field '$keyField' can't be used as key.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Invalid field '$keyField' can't be used as key.");
|
||||
}
|
||||
$this->_keyField = $keyField;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ abstract class AbstractEntityPersister
|
||||
$mapping = $this->_classMetadata->getFieldMapping($fieldName);
|
||||
return $mapping['inherited'];
|
||||
}
|
||||
throw new DoctrineException("Unable to find defining class of field '$fieldName'.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Unable to find defining class of field '$fieldName'.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,7 +328,7 @@ class Query extends AbstractQuery
|
||||
public function setResultCache($resultCache)
|
||||
{
|
||||
if ($resultCache !== null && ! ($resultCache instanceof \Doctrine\ORM\Cache\Cache)) {
|
||||
throw new DoctrineException(
|
||||
\Doctrine\Common\DoctrineException::updateMe(
|
||||
'Method setResultCache() accepts only an instance of Doctrine_Cache_Interface or null.'
|
||||
);
|
||||
}
|
||||
@ -410,7 +410,7 @@ class Query extends AbstractQuery
|
||||
public function setQueryCache($queryCache)
|
||||
{
|
||||
if ($queryCache !== null && ! ($queryCache instanceof \Doctrine\ORM\Cache\Cache)) {
|
||||
throw new DoctrineException(
|
||||
\Doctrine\Common\DoctrineException::updateMe(
|
||||
'Method setResultCache() accepts only an instance of Doctrine_ORM_Cache_Interface or null.'
|
||||
);
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ class ArithmeticExpression extends Node
|
||||
|
||||
public function setSimpleArithmeticExpression($simpleArithmeticExpr)
|
||||
{
|
||||
if ($this->_subselect) throw new Doctrine_Exception;
|
||||
if ($this->_subselect) throw \Doctrine\Common\DoctrineException::updateMe();
|
||||
$this->_simpleArithmeticExpression = $simpleArithmeticExpr;
|
||||
}
|
||||
|
||||
public function setSubselect($subselect)
|
||||
{
|
||||
if ($this->_simpleArithmeticExpression) throw new Doctrine_Exception;
|
||||
if ($this->_simpleArithmeticExpression) throw \Doctrine\Common\DoctrineException::updateMe();
|
||||
$this->_subselect = $subselect;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ class Parser
|
||||
$message .= "'{$this->_lexer->lookahead['value']}'";
|
||||
}
|
||||
|
||||
throw new QueryException($message);
|
||||
throw \Doctrine\Common\DoctrineException::updateMe($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -259,7 +259,7 @@ class Parser
|
||||
$token = $this->_lexer->token;
|
||||
}
|
||||
//TODO: Include $token in $message
|
||||
throw new QueryException($message);
|
||||
throw \Doctrine\Common\DoctrineException::updateMe($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1139,7 +1139,7 @@ class Parser
|
||||
default:
|
||||
$this->syntaxError();
|
||||
}
|
||||
throw new QueryException("Not yet implemented.");
|
||||
throw \Doctrine\Common\DoctrineException::updateMe("Not yet implemented.");
|
||||
//TODO...
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,9 @@ class SqlWalker
|
||||
$sql .= $sqlTableAlias . '.' . $class->getColumnName($fieldName) .
|
||||
' AS ' . $sqlTableAlias . '__' . $class->getColumnName($fieldName);
|
||||
} else if ($pathExpression->isSimpleStateFieldAssociationPathExpression()) {
|
||||
throw new DoctrineException("Not yet implemented.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Not yet implemented.");
|
||||
} else {
|
||||
throw new DoctrineException("Encountered invalid PathExpression during SQL construction.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Encountered invalid PathExpression during SQL construction.");
|
||||
}
|
||||
}
|
||||
else if ($selectExpression->getExpression() instanceof AST\AggregateExpression) {
|
||||
@ -380,9 +380,9 @@ class SqlWalker
|
||||
$sqlTableAlias = $this->_dqlToSqlAliasMap[$dqlAlias];
|
||||
$sql .= $sqlTableAlias . '.' . $class->getColumnName($fieldName);
|
||||
} else if ($pathExpr->isSimpleStateFieldAssociationPathExpression()) {
|
||||
throw new DoctrineException("Not yet implemented.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Not yet implemented.");
|
||||
} else {
|
||||
throw new DoctrineException("Encountered invalid PathExpression during SQL construction.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Encountered invalid PathExpression during SQL construction.");
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ class UnitOfWork
|
||||
$this->_entityChangeSets[$oid] = $changeSet;
|
||||
$this->_originalEntityData[$oid] = $data;
|
||||
} else if ($state == self::STATE_DELETED) {
|
||||
throw new DoctrineException("Deleted entity in collection detected during flush.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Deleted entity in collection detected during flush.");
|
||||
}
|
||||
// MANAGED associated entities are already taken into account
|
||||
// during changeset calculation anyway, since they are in the identity map.
|
||||
@ -605,13 +605,13 @@ class UnitOfWork
|
||||
$oid = spl_object_hash($entity);
|
||||
|
||||
if (isset($this->_entityUpdates[$oid])) {
|
||||
throw new DoctrineException("Dirty object can't be registered as new.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Dirty object can't be registered as new.");
|
||||
}
|
||||
if (isset($this->_entityDeletions[$oid])) {
|
||||
throw new DoctrineException("Removed object can't be registered as new.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Removed object can't be registered as new.");
|
||||
}
|
||||
if (isset($this->_entityInsertions[$oid])) {
|
||||
throw new DoctrineException("Object already registered as new. Can't register twice.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Object already registered as new. Can't register twice.");
|
||||
}
|
||||
|
||||
$this->_entityInsertions[$oid] = $entity;
|
||||
@ -642,11 +642,11 @@ class UnitOfWork
|
||||
{
|
||||
$oid = spl_object_hash($entity);
|
||||
if ( ! isset($this->_entityIdentifiers[$oid])) {
|
||||
throw new DoctrineException("Entity without identity "
|
||||
\Doctrine\Common\DoctrineException::updateMe("Entity without identity "
|
||||
. "can't be registered as dirty.");
|
||||
}
|
||||
if (isset($this->_entityDeletions[$oid])) {
|
||||
throw new DoctrineException("Removed object can't be registered as dirty.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Removed object can't be registered as dirty.");
|
||||
}
|
||||
|
||||
if ( ! isset($this->_entityUpdates[$oid]) && ! isset($this->_entityInsertions[$oid])) {
|
||||
@ -784,7 +784,7 @@ class UnitOfWork
|
||||
$classMetadata = $this->_em->getClassMetadata(get_class($entity));
|
||||
$idHash = $this->getIdentifierHash($this->_entityIdentifiers[spl_object_hash($entity)]);
|
||||
if ($idHash === '') {
|
||||
throw new DoctrineException("Entity with oid '" . spl_object_hash($entity)
|
||||
\Doctrine\Common\DoctrineException::updateMe("Entity with oid '" . spl_object_hash($entity)
|
||||
. "' has no identity and therefore can't be added to the identity map.");
|
||||
}
|
||||
$className = $classMetadata->getRootClassName();
|
||||
@ -827,7 +827,7 @@ class UnitOfWork
|
||||
$classMetadata = $this->_em->getClassMetadata(get_class($entity));
|
||||
$idHash = $this->getIdentifierHash($this->_entityIdentifiers[$oid]);
|
||||
if ($idHash === '') {
|
||||
throw new DoctrineException("Entity with oid '" . spl_object_hash($entity)
|
||||
\Doctrine\Common\DoctrineException::updateMe("Entity with oid '" . spl_object_hash($entity)
|
||||
. "' has no identity and therefore can't be removed from the identity map.");
|
||||
}
|
||||
$className = $classMetadata->getRootClassName();
|
||||
@ -989,7 +989,7 @@ class UnitOfWork
|
||||
$this->registerNew($entity);
|
||||
break;
|
||||
case self::STATE_DETACHED:
|
||||
throw new DoctrineException("Behavior of save() for a detached entity "
|
||||
\Doctrine\Common\DoctrineException::updateMe("Behavior of save() for a detached entity "
|
||||
. "is not yet defined.");
|
||||
case self::STATE_DELETED:
|
||||
// entity becomes managed again
|
||||
@ -1003,7 +1003,7 @@ class UnitOfWork
|
||||
break;
|
||||
default:
|
||||
//TODO: throw UnitOfWorkException::invalidEntityState()
|
||||
throw new DoctrineException("Encountered invalid entity state.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Encountered invalid entity state.");
|
||||
}
|
||||
$this->_cascadeSave($entity, $visited, $insertNow);
|
||||
}
|
||||
@ -1045,9 +1045,9 @@ class UnitOfWork
|
||||
$this->registerDeleted($entity);
|
||||
break;
|
||||
case self::STATE_DETACHED:
|
||||
throw new DoctrineException("A detached entity can't be deleted.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("A detached entity can't be deleted.");
|
||||
default:
|
||||
throw new DoctrineException("Encountered invalid entity state.");
|
||||
\Doctrine\Common\DoctrineException::updateMe("Encountered invalid entity state.");
|
||||
}
|
||||
$this->_cascadeDelete($entity, $visited);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user