Commit 5582f07b authored by jwage's avatar jwage

[2.0] Intermediate refactoring for new exception handling

parent 62779913
...@@ -5,6 +5,7 @@ namespace Doctrine\Common; ...@@ -5,6 +5,7 @@ namespace Doctrine\Common;
class DoctrineException extends \Exception class DoctrineException extends \Exception
{ {
private $_innerException; private $_innerException;
private static $_messages = array();
public function __construct($message = "", Exception $innerException = null) public function __construct($message = "", Exception $innerException = null)
{ {
...@@ -21,5 +22,26 @@ class DoctrineException extends \Exception ...@@ -21,5 +22,26 @@ class DoctrineException extends \Exception
{ {
return new self("The method '$method' is not implemented in class '$class'."); return new self("The method '$method' is not implemented in class '$class'.");
} }
}
public static function __callStatic($method, $arguments)
{
$end = end($arguments);
if ($end instanceof Exception) {
$this->_innerException = $end;
unset($arguments[count($arguments) - 1]);
}
if (isset(self::$_messages[$method])) {
$message = sprintf(self::$_messages[$method], $arguments);
} else {
$message = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $method));
$message = ucfirst(str_replace('_', ' ', $message));
$args = array();
foreach ($arguments as $argument) {
$args[] = var_export($argument, true);
}
$message .= ' (' . implode(', ', $args) . ')';
}
return new self($message);
}
}
\ No newline at end of file
...@@ -688,7 +688,7 @@ class Connection ...@@ -688,7 +688,7 @@ class Connection
public function commit() public function commit()
{ {
if ($this->_transactionNestingLevel == 0) { if ($this->_transactionNestingLevel == 0) {
throw new DoctrineException("Commit failed. There is no active transaction."); throw ConnectionException::commitFailedNoActiveTransaction();
} }
$this->connect(); $this->connect();
...@@ -717,7 +717,7 @@ class Connection ...@@ -717,7 +717,7 @@ class Connection
public function rollback() public function rollback()
{ {
if ($this->_transactionNestingLevel == 0) { if ($this->_transactionNestingLevel == 0) {
throw new Doctrine_Exception("Rollback failed. There is no active transaction."); throw ConnectionException::rollbackFailedNoActiveTransaction();
} }
$this->connect(); $this->connect();
......
<?php
namespace Doctrine\DBAL\Exceptions;
use Doctrine\Common\DoctrineException;
/**
*
*
* @package Doctrine
* @subpackage Hydrate
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1080 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class DBALException 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'.");
}
}
\ No newline at end of file
...@@ -130,7 +130,7 @@ abstract class AbstractPlatform ...@@ -130,7 +130,7 @@ abstract class AbstractPlatform
*/ */
public function getRegexpExpression() public function getRegexpExpression()
{ {
throw new Doctrine_Expression_Exception('Regular expression operator is not supported by this database driver.'); throw \Doctrine\Common\DoctrineException::updateMe('Regular expression operator is not supported by this database driver.');
} }
/** /**
...@@ -350,7 +350,7 @@ abstract class AbstractPlatform ...@@ -350,7 +350,7 @@ abstract class AbstractPlatform
*/ */
public function getSoundexExpression($value) public function getSoundexExpression($value)
{ {
throw new Doctrine_Expression_Exception('SQL soundex function not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('SQL soundex function not supported by this driver.');
} }
/** /**
...@@ -700,7 +700,7 @@ abstract class AbstractPlatform ...@@ -700,7 +700,7 @@ abstract class AbstractPlatform
$column = $this->getIdentifier($column); $column = $this->getIdentifier($column);
if (count($values) == 0) { if (count($values) == 0) {
throw new Doctrine_Expression_Exception('Values array for IN operator should not be empty.'); throw \Doctrine\Common\DoctrineException::updateMe('Values array for IN operator should not be empty.');
} }
return $column . ' IN (' . implode(', ', $values) . ')'; return $column . ' IN (' . implode(', ', $values) . ')';
} }
...@@ -783,7 +783,7 @@ abstract class AbstractPlatform ...@@ -783,7 +783,7 @@ abstract class AbstractPlatform
*/ */
public function getGuidExpression() public function getGuidExpression()
{ {
throw new Doctrine_Expression_Exception('method not implemented'); throw \Doctrine\Common\DoctrineException::updateMe('method not implemented');
} }
/** /**
...@@ -846,7 +846,7 @@ abstract class AbstractPlatform ...@@ -846,7 +846,7 @@ abstract class AbstractPlatform
*/ */
public function getListDatabasesSql() public function getListDatabasesSql()
{ {
throw new Doctrine_Export_Exception('List databases not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List databases not supported by this driver.');
} }
/** /**
...@@ -856,7 +856,7 @@ abstract class AbstractPlatform ...@@ -856,7 +856,7 @@ abstract class AbstractPlatform
*/ */
public function getListFunctionsSql() public function getListFunctionsSql()
{ {
throw new Doctrine_Export_Exception('List functions not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List functions not supported by this driver.');
} }
/** /**
...@@ -866,7 +866,7 @@ abstract class AbstractPlatform ...@@ -866,7 +866,7 @@ abstract class AbstractPlatform
*/ */
public function getListTriggersSql() public function getListTriggersSql()
{ {
throw new Doctrine_Export_Exception('List triggers not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List triggers not supported by this driver.');
} }
/** /**
...@@ -876,7 +876,7 @@ abstract class AbstractPlatform ...@@ -876,7 +876,7 @@ abstract class AbstractPlatform
*/ */
public function getListSequencesSql() public function getListSequencesSql()
{ {
throw new Doctrine_Export_Exception('List sequences not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List sequences not supported by this driver.');
} }
/** /**
...@@ -886,7 +886,7 @@ abstract class AbstractPlatform ...@@ -886,7 +886,7 @@ abstract class AbstractPlatform
*/ */
public function getListTableConstraintsSql() public function getListTableConstraintsSql()
{ {
throw new Doctrine_Export_Exception('List table constraints not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List table constraints not supported by this driver.');
} }
/** /**
...@@ -896,7 +896,7 @@ abstract class AbstractPlatform ...@@ -896,7 +896,7 @@ abstract class AbstractPlatform
*/ */
public function getListTableColumnsSql() public function getListTableColumnsSql()
{ {
throw new Doctrine_Export_Exception('List table columns not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List table columns not supported by this driver.');
} }
/** /**
...@@ -906,7 +906,7 @@ abstract class AbstractPlatform ...@@ -906,7 +906,7 @@ abstract class AbstractPlatform
*/ */
public function getListTablesSql() public function getListTablesSql()
{ {
throw new Doctrine_Export_Exception('List tables not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List tables not supported by this driver.');
} }
/** /**
...@@ -916,7 +916,7 @@ abstract class AbstractPlatform ...@@ -916,7 +916,7 @@ abstract class AbstractPlatform
*/ */
public function getListUsersSql() public function getListUsersSql()
{ {
throw new Doctrine_Export_Exception('List users not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List users not supported by this driver.');
} }
/** /**
...@@ -926,7 +926,7 @@ abstract class AbstractPlatform ...@@ -926,7 +926,7 @@ abstract class AbstractPlatform
*/ */
public function getListViewsSql() public function getListViewsSql()
{ {
throw new Doctrine_Export_Exception('List views not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('List views not supported by this driver.');
} }
/** /**
...@@ -966,7 +966,7 @@ abstract class AbstractPlatform ...@@ -966,7 +966,7 @@ abstract class AbstractPlatform
*/ */
public function getDropSequenceSql() public function getDropSequenceSql()
{ {
throw new Doctrine_Export_Exception('Drop sequence not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('Drop sequence not supported by this driver.');
} }
/** /**
...@@ -974,7 +974,7 @@ abstract class AbstractPlatform ...@@ -974,7 +974,7 @@ abstract class AbstractPlatform
*/ */
public function getSequenceNextValSql($sequenceName) public function getSequenceNextValSql($sequenceName)
{ {
throw new Doctrine_Export_Exception('Sequences not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('Sequences not supported by this driver.');
} }
/** /**
...@@ -984,7 +984,7 @@ abstract class AbstractPlatform ...@@ -984,7 +984,7 @@ abstract class AbstractPlatform
*/ */
public function getCreateDatabaseSql($database) public function getCreateDatabaseSql($database)
{ {
throw new Doctrine_Export_Exception('Create database not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('Create database not supported by this driver.');
} }
/** /**
...@@ -995,10 +995,10 @@ abstract class AbstractPlatform ...@@ -995,10 +995,10 @@ abstract class AbstractPlatform
public function getCreateTableSql($table, array $columns, array $options = array()) public function getCreateTableSql($table, array $columns, array $options = array())
{ {
if ( ! $table) { if ( ! $table) {
throw new Doctrine_Export_Exception('no valid table name specified'); throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
} }
if (empty($columns)) { if (empty($columns)) {
throw new Doctrine_Export_Exception('no fields specified for table ' . $name); throw \Doctrine\Common\DoctrineException::updateMe('no fields specified for table ' . $name);
} }
$queryFields = $this->getFieldDeclarationListSql($columns); $queryFields = $this->getFieldDeclarationListSql($columns);
...@@ -1042,7 +1042,7 @@ abstract class AbstractPlatform ...@@ -1042,7 +1042,7 @@ abstract class AbstractPlatform
*/ */
public function getCreateSequenceSql($sequenceName, $start = 1, array $options) public function getCreateSequenceSql($sequenceName, $start = 1, array $options)
{ {
throw new Doctrine_Export_Exception('Create sequence not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('Create sequence not supported by this driver.');
} }
/** /**
...@@ -1103,7 +1103,7 @@ abstract class AbstractPlatform ...@@ -1103,7 +1103,7 @@ abstract class AbstractPlatform
$type = strtoupper($definition['type']) . ' '; $type = strtoupper($definition['type']) . ' ';
break; break;
default: default:
throw new Doctrine_Export_Exception('Unknown index type ' . $definition['type']); throw \Doctrine\Common\DoctrineException::updateMe('Unknown index type ' . $definition['type']);
} }
} }
...@@ -1199,7 +1199,7 @@ abstract class AbstractPlatform ...@@ -1199,7 +1199,7 @@ abstract class AbstractPlatform
*/ */
public function getAlterTableSql($name, array $changes, $check = false) public function getAlterTableSql($name, array $changes, $check = false)
{ {
throw new Doctrine_Export_Exception('Alter table not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('Alter table not supported by this driver.');
} }
/** /**
...@@ -1407,12 +1407,12 @@ abstract class AbstractPlatform ...@@ -1407,12 +1407,12 @@ abstract class AbstractPlatform
if (strtolower($definition['type']) == 'unique') { if (strtolower($definition['type']) == 'unique') {
$type = strtoupper($definition['type']) . ' '; $type = strtoupper($definition['type']) . ' ';
} else { } else {
throw new Doctrine_Export_Exception('Unknown index type ' . $definition['type']); throw \Doctrine\Common\DoctrineException::updateMe('Unknown index type ' . $definition['type']);
} }
} }
if ( ! isset($definition['fields']) || ! is_array($definition['fields'])) { if ( ! isset($definition['fields']) || ! is_array($definition['fields'])) {
throw new Doctrine_Export_Exception('No index columns given.'); throw \Doctrine\Common\DoctrineException::updateMe('No index columns given.');
} }
$query = $type . 'INDEX ' . $name; $query = $type . 'INDEX ' . $name;
...@@ -1468,7 +1468,7 @@ abstract class AbstractPlatform ...@@ -1468,7 +1468,7 @@ abstract class AbstractPlatform
*/ */
public function getShowDatabasesSql() public function getShowDatabasesSql()
{ {
throw new Doctrine_Export_Exception('Show databases not supported by this driver.'); throw \Doctrine\Common\DoctrineException::updateMe('Show databases not supported by this driver.');
} }
/** /**
...@@ -1561,7 +1561,7 @@ abstract class AbstractPlatform ...@@ -1561,7 +1561,7 @@ abstract class AbstractPlatform
return $upper; return $upper;
break; break;
default: default:
throw new Doctrine_Export_Exception('Unknown foreign key referential action \'' . $upper . '\' given.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown foreign key referential action \'' . $upper . '\' given.');
} }
} }
...@@ -1581,13 +1581,13 @@ abstract class AbstractPlatform ...@@ -1581,13 +1581,13 @@ abstract class AbstractPlatform
$sql .= 'FOREIGN KEY ('; $sql .= 'FOREIGN KEY (';
if ( ! isset($definition['local'])) { if ( ! isset($definition['local'])) {
throw new Doctrine_Export_Exception('Local reference field missing from definition.'); throw \Doctrine\Common\DoctrineException::updateMe('Local reference field missing from definition.');
} }
if ( ! isset($definition['foreign'])) { if ( ! isset($definition['foreign'])) {
throw new Doctrine_Export_Exception('Foreign reference field missing from definition.'); throw \Doctrine\Common\DoctrineException::updateMe('Foreign reference field missing from definition.');
} }
if ( ! isset($definition['foreignTable'])) { if ( ! isset($definition['foreignTable'])) {
throw new Doctrine_Export_Exception('Foreign reference table missing from definition.'); throw \Doctrine\Common\DoctrineException::updateMe('Foreign reference table missing from definition.');
} }
if ( ! is_array($definition['local'])) { if ( ! is_array($definition['local'])) {
...@@ -1662,7 +1662,7 @@ abstract class AbstractPlatform ...@@ -1662,7 +1662,7 @@ abstract class AbstractPlatform
*/ */
public function getMatchPatternExpression($pattern, $operator = null, $field = null) public function getMatchPatternExpression($pattern, $operator = null, $field = null)
{ {
throw new Doctrine_Expression_Exception("Method not implemented."); throw \Doctrine\Common\DoctrineException::updateMe("Method not implemented.");
} }
/** /**
......
...@@ -86,7 +86,7 @@ class FirebirdPlatform extends AbstractPlatform ...@@ -86,7 +86,7 @@ class FirebirdPlatform extends AbstractPlatform
public function getNativeDeclaration($field) public function getNativeDeclaration($field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
case 'varchar': case 'varchar':
...@@ -126,7 +126,7 @@ class FirebirdPlatform extends AbstractPlatform ...@@ -126,7 +126,7 @@ class FirebirdPlatform extends AbstractPlatform
return 'DECIMAL('.$length.','.$scale.')'; return 'DECIMAL('.$length.','.$scale.')';
} }
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
} }
/** /**
...@@ -211,7 +211,7 @@ class FirebirdPlatform extends AbstractPlatform ...@@ -211,7 +211,7 @@ class FirebirdPlatform extends AbstractPlatform
$length = null; $length = null;
break; break;
default: default:
throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$dbType); throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: '.$dbType);
} }
return array('type' => $type, return array('type' => $type,
......
...@@ -42,7 +42,7 @@ class InformixPlatform extends AbstractPlatform ...@@ -42,7 +42,7 @@ class InformixPlatform extends AbstractPlatform
public function getNativeDeclaration($field) public function getNativeDeclaration($field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
case 'char': case 'char':
...@@ -90,7 +90,7 @@ class InformixPlatform extends AbstractPlatform ...@@ -90,7 +90,7 @@ class InformixPlatform extends AbstractPlatform
case 'decimal': case 'decimal':
return 'DECIMAL'; return 'DECIMAL';
} }
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
} }
} }
......
...@@ -30,7 +30,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -30,7 +30,7 @@ class MsSqlPlatform extends AbstractPlatform
$offset = intval($offset); $offset = intval($offset);
if ($offset < 0) { if ($offset < 0) {
throw new Doctrine_Connection_Exception("LIMIT argument offset=$offset is not valid"); throw \Doctrine\Common\DoctrineException::updateMe("LIMIT argument offset=$offset is not valid");
} }
$orderby = stristr($query, 'ORDER BY'); $orderby = stristr($query, 'ORDER BY');
...@@ -147,7 +147,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -147,7 +147,7 @@ class MsSqlPlatform extends AbstractPlatform
public function getNativeDeclaration($field) public function getNativeDeclaration($field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
case 'array': case 'array':
...@@ -200,7 +200,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -200,7 +200,7 @@ class MsSqlPlatform extends AbstractPlatform
return 'DECIMAL('.$length.','.$scale.')'; return 'DECIMAL('.$length.','.$scale.')';
} }
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
} }
/** /**
...@@ -272,7 +272,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -272,7 +272,7 @@ class MsSqlPlatform extends AbstractPlatform
$length = null; $length = null;
break; break;
default: default:
throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$db_type); throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: '.$db_type);
} }
return array('type' => $type, return array('type' => $type,
......
...@@ -185,7 +185,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -185,7 +185,7 @@ class MySqlPlatform extends AbstractPlatform
$match = $field.'LIKE BINARY '; $match = $field.'LIKE BINARY ';
break; break;
default: default:
throw new Doctrine_Expression_Mysql_Exception('not a supported operator type:'. $operator); throw \Doctrine\Common\DoctrineException::updateMe('not a supported operator type:'. $operator);
} }
} }
$match.= "'"; $match.= "'";
...@@ -297,7 +297,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -297,7 +297,7 @@ class MySqlPlatform extends AbstractPlatform
public function getNativeDeclaration(array $field) public function getNativeDeclaration(array $field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
...@@ -367,7 +367,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -367,7 +367,7 @@ class MySqlPlatform extends AbstractPlatform
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'DECIMAL('.$length.','.$scale.')'; return 'DECIMAL('.$length.','.$scale.')';
} }
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
} }
/** /**
...@@ -520,7 +520,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -520,7 +520,7 @@ class MySqlPlatform extends AbstractPlatform
$length = null; $length = null;
break; break;
default: default:
throw new Doctrine_DataDict_Exception('unknown database attribute type: ' . $dbType); throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: ' . $dbType);
} }
$length = ((int) $length == 0) ? null : (int) $length; $length = ((int) $length == 0) ? null : (int) $length;
...@@ -678,10 +678,10 @@ class MySqlPlatform extends AbstractPlatform ...@@ -678,10 +678,10 @@ class MySqlPlatform extends AbstractPlatform
public function getCreateTableSql($name, array $fields, array $options = array()) public function getCreateTableSql($name, array $fields, array $options = array())
{ {
if ( ! $name) { if ( ! $name) {
throw new Doctrine_Export_Exception('no valid table name specified'); throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
} }
if (empty($fields)) { if (empty($fields)) {
throw new Doctrine_Export_Exception('no fields specified for table "'.$name.'"'); throw \Doctrine\Common\DoctrineException::updateMe('no fields specified for table "'.$name.'"');
} }
$queryFields = $this->getFieldDeclarationListSql($fields); $queryFields = $this->getFieldDeclarationListSql($fields);
...@@ -866,7 +866,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -866,7 +866,7 @@ class MySqlPlatform extends AbstractPlatform
public function getAlterTableSql($name, array $changes, $check = false) public function getAlterTableSql($name, array $changes, $check = false)
{ {
if ( ! $name) { if ( ! $name) {
throw new Doctrine_Export_Exception('no valid table name specified'); throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
} }
foreach ($changes as $changeName => $change) { foreach ($changes as $changeName => $change) {
switch ($changeName) { switch ($changeName) {
...@@ -877,7 +877,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -877,7 +877,7 @@ class MySqlPlatform extends AbstractPlatform
case 'name': case 'name':
break; break;
default: default:
throw new Doctrine_Export_Exception('change type "' . $changeName . '" not yet supported'); throw \Doctrine\Common\DoctrineException::updateMe('change type "' . $changeName . '" not yet supported');
} }
} }
...@@ -1003,7 +1003,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -1003,7 +1003,7 @@ class MySqlPlatform extends AbstractPlatform
$type = strtoupper($definition['type']) . ' '; $type = strtoupper($definition['type']) . ' ';
break; break;
default: default:
throw new Doctrine_Export_Exception('Unknown index type ' . $definition['type']); throw \Doctrine\Common\DoctrineException::updateMe('Unknown index type ' . $definition['type']);
} }
} }
$query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table; $query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table;
...@@ -1139,12 +1139,12 @@ class MySqlPlatform extends AbstractPlatform ...@@ -1139,12 +1139,12 @@ class MySqlPlatform extends AbstractPlatform
$type = strtoupper($definition['type']) . ' '; $type = strtoupper($definition['type']) . ' ';
break; break;
default: default:
throw new Doctrine_Export_Exception('Unknown index type ' . $definition['type']); throw \Doctrine\Common\DoctrineException::updateMe('Unknown index type ' . $definition['type']);
} }
} }
if ( ! isset($definition['fields'])) { if ( ! isset($definition['fields'])) {
throw new Doctrine_Export_Exception('No index columns given.'); throw \Doctrine\Common\DoctrineException::updateMe('No index columns given.');
} }
if ( ! is_array($definition['fields'])) { if ( ! is_array($definition['fields'])) {
$definition['fields'] = array($definition['fields']); $definition['fields'] = array($definition['fields']);
...@@ -1185,7 +1185,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -1185,7 +1185,7 @@ class MySqlPlatform extends AbstractPlatform
$fieldString .= ' ' . $sort; $fieldString .= ' ' . $sort;
break; break;
default: default:
throw new Doctrine_Export_Exception('Unknown index sorting option given.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown index sorting option given.');
} }
} }
} else { } else {
......
...@@ -95,7 +95,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -95,7 +95,7 @@ class OraclePlatform extends AbstractPlatform
// NOTE: no composite key support // NOTE: no composite key support
$columnNames = $rootClass->getIdentifierColumnNames(); $columnNames = $rootClass->getIdentifierColumnNames();
if (count($columnNames) > 1) { if (count($columnNames) > 1) {
throw new Doctrine_Connection_Exception("Composite keys in LIMIT queries are " throw \Doctrine\Common\DoctrineException::updateMe("Composite keys in LIMIT queries are "
. "currently not supported."); . "currently not supported.");
} }
$column = $columnNames[0]; $column = $columnNames[0];
...@@ -191,7 +191,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -191,7 +191,7 @@ class OraclePlatform extends AbstractPlatform
public function getNativeDeclaration(array $field) public function getNativeDeclaration(array $field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
case 'string': case 'string':
...@@ -231,7 +231,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -231,7 +231,7 @@ class OraclePlatform extends AbstractPlatform
return 'NUMBER(*,'.$scale.')'; return 'NUMBER(*,'.$scale.')';
default: default:
} }
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
} }
/** /**
...@@ -245,7 +245,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -245,7 +245,7 @@ class OraclePlatform extends AbstractPlatform
public function getPortableDeclaration(array $field) public function getPortableDeclaration(array $field)
{ {
if ( ! isset($field['data_type'])) { if ( ! isset($field['data_type'])) {
throw new Doctrine_DataDict_Exception('Native oracle definition must have a data_type key specified'); throw \Doctrine\Common\DoctrineException::updateMe('Native oracle definition must have a data_type key specified');
} }
$dbType = strtolower($field['data_type']); $dbType = strtolower($field['data_type']);
...@@ -325,7 +325,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -325,7 +325,7 @@ class OraclePlatform extends AbstractPlatform
case 'rowid': case 'rowid':
case 'urowid': case 'urowid':
default: default:
throw new Doctrine_DataDict_Exception('unknown database attribute type: ' . $dbType); throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: ' . $dbType);
} }
return array('type' => $type, return array('type' => $type,
......
...@@ -101,7 +101,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -101,7 +101,7 @@ class PostgreSqlPlatform extends AbstractPlatform
public function getNativeDeclaration(array $field) public function getNativeDeclaration(array $field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
case 'char': case 'char':
...@@ -161,7 +161,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -161,7 +161,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'NUMERIC('.$length.','.$scale.')'; return 'NUMERIC('.$length.','.$scale.')';
} }
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
} }
/** /**
...@@ -293,7 +293,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -293,7 +293,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$length = null; $length = null;
break; break;
default: default:
throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$dbType); throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: '.$dbType);
} }
return array('type' => $type, return array('type' => $type,
...@@ -461,7 +461,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -461,7 +461,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$match = $field.'LIKE '; $match = $field.'LIKE ';
break; break;
default: default:
throw new Doctrine_Expression_Pgsql_Exception('not a supported operator type:'. $operator); throw \Doctrine\Common\DoctrineException::updateMe('not a supported operator type:'. $operator);
} }
} }
$match.= "'"; $match.= "'";
...@@ -766,7 +766,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -766,7 +766,7 @@ class PostgreSqlPlatform extends AbstractPlatform
case 'rename': case 'rename':
break; break;
default: default:
throw new Doctrine_Export_Exception('change type "' . $changeName . '\" not yet supported'); throw \Doctrine\Common\DoctrineException::updateMe('change type "' . $changeName . '\" not yet supported');
} }
} }
...@@ -798,7 +798,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -798,7 +798,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$serverInfo = $this->getServerVersion(); $serverInfo = $this->getServerVersion();
if (is_array($serverInfo) && $serverInfo['major'] < 8) { if (is_array($serverInfo) && $serverInfo['major'] < 8) {
throw new Doctrine_Export_Exception('changing column type for "'.$field['type'].'\" requires PostgreSQL 8.0 or above'); throw \Doctrine\Common\DoctrineException::updateMe('changing column type for "'.$field['type'].'\" requires PostgreSQL 8.0 or above');
} }
$query = 'ALTER ' . $fieldName . ' TYPE ' . $this->getTypeDeclarationSql($field['definition']); $query = 'ALTER ' . $fieldName . ' TYPE ' . $this->getTypeDeclarationSql($field['definition']);
$sql[] = 'ALTER TABLE ' . $name . ' ' . $query; $sql[] = 'ALTER TABLE ' . $name . ' ' . $query;
...@@ -875,10 +875,10 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -875,10 +875,10 @@ class PostgreSqlPlatform extends AbstractPlatform
public function getCreateTableSql($name, array $fields, array $options = array()) public function getCreateTableSql($name, array $fields, array $options = array())
{ {
if ( ! $name) { if ( ! $name) {
throw new Doctrine_Export_Exception('no valid table name specified'); throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
} }
if (empty($fields)) { if (empty($fields)) {
throw new Doctrine_Export_Exception('no fields specified for table ' . $name); throw \Doctrine\Common\DoctrineException::updateMe('no fields specified for table ' . $name);
} }
$queryFields = $this->getFieldDeclarationListSql($fields); $queryFields = $this->getFieldDeclarationListSql($fields);
......
...@@ -195,7 +195,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -195,7 +195,7 @@ class SqlitePlatform extends AbstractPlatform
public function getNativeDeclaration(array $field) public function getNativeDeclaration(array $field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
case 'text': case 'text':
...@@ -255,7 +255,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -255,7 +255,7 @@ class SqlitePlatform extends AbstractPlatform
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES); $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'DECIMAL('.$length.','.$scale.')'; return 'DECIMAL('.$length.','.$scale.')';
} }
throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
} }
/** /**
...@@ -372,7 +372,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -372,7 +372,7 @@ class SqlitePlatform extends AbstractPlatform
$length = null; $length = null;
break; break;
default: default:
throw new Doctrine_DataDict_Exception('unknown database attribute type: '.$dbType); throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: '.$dbType);
} }
return array('type' => $type, return array('type' => $type,
...@@ -488,11 +488,11 @@ class SqlitePlatform extends AbstractPlatform ...@@ -488,11 +488,11 @@ class SqlitePlatform extends AbstractPlatform
public function getCreateTableSql($name, array $fields, array $options = array()) public function getCreateTableSql($name, array $fields, array $options = array())
{ {
if ( ! $name) { if ( ! $name) {
throw new Doctrine_Exception('no valid table name specified'); throw ConnectionException::invalidTableName($name);
} }
if (empty($fields)) { if (empty($fields)) {
throw new Doctrine_Exception('no fields specified for table '.$name); throw ConnectionException::noFieldsSpecifiedForTable($name);
} }
$queryFields = $this->getFieldDeclarationListSql($fields); $queryFields = $this->getFieldDeclarationListSql($fields);
......
...@@ -135,7 +135,7 @@ class FirebirdSchemaManager extends AbstractSchemaManager ...@@ -135,7 +135,7 @@ class FirebirdSchemaManager extends AbstractSchemaManager
*/ */
public function createDatabase($name) public function createDatabase($name)
{ {
throw new Doctrine_Export_Exception( throw \Doctrine\Common\DoctrineException::updateMe(
'PHP Interbase API does not support direct queries. You have to ' . 'PHP Interbase API does not support direct queries. You have to ' .
'create the db manually by using isql command or a similar program'); 'create the db manually by using isql command or a similar program');
} }
...@@ -148,7 +148,7 @@ class FirebirdSchemaManager extends AbstractSchemaManager ...@@ -148,7 +148,7 @@ class FirebirdSchemaManager extends AbstractSchemaManager
*/ */
public function dropDatabase($name) public function dropDatabase($name)
{ {
throw new Doctrine_Export_Exception( throw \Doctrine\Common\DoctrineException::updateMe(
'PHP Interbase API does not support direct queries. You have ' . 'PHP Interbase API does not support direct queries. You have ' .
'to drop the db manually by using isql command or a similar program'); 'to drop the db manually by using isql command or a similar program');
} }
...@@ -275,20 +275,17 @@ class FirebirdSchemaManager extends AbstractSchemaManager ...@@ -275,20 +275,17 @@ class FirebirdSchemaManager extends AbstractSchemaManager
foreach ($changes as $change_name => $change) { foreach ($changes as $change_name => $change) {
switch ($change_name) { switch ($change_name) {
case 'notnull': case 'notnull':
throw new Doctrine_DataDict_Exception('it is not supported changes to field not null constraint'); throw \Doctrine\Common\DoctrineException::updateMe('it is not supported changes to field not null constraint');
case 'default': case 'default':
throw new Doctrine_DataDict_Exception('it is not supported changes to field default value'); throw \Doctrine\Common\DoctrineException::updateMe('it is not supported changes to field default value');
case 'length': case 'length':
/*
return throw new Doctrine_DataDict_Firebird_Exception('it is not supported changes to field default length');
*/
case 'unsigned': case 'unsigned':
case 'type': case 'type':
case 'declaration': case 'declaration':
case 'definition': case 'definition':
break; break;
default: default:
throw new Doctrine_DataDict_Exception('it is not supported change of type' . $change_name); throw \Doctrine\Common\DoctrineException::updateMe('it is not supported change of type' . $change_name);
} }
} }
return true; return true;
...@@ -413,7 +410,7 @@ class FirebirdSchemaManager extends AbstractSchemaManager ...@@ -413,7 +410,7 @@ class FirebirdSchemaManager extends AbstractSchemaManager
} }
break; break;
default: default:
throw new Doctrine_DataDict_Exception('change type ' . $changeName . ' not yet supported'); throw \Doctrine\Common\DoctrineException::updateMe('change type ' . $changeName . ' not yet supported');
} }
} }
if ($check) { if ($check) {
...@@ -621,10 +618,10 @@ class FirebirdSchemaManager extends AbstractSchemaManager ...@@ -621,10 +618,10 @@ class FirebirdSchemaManager extends AbstractSchemaManager
try { try {
$this->dropSequence($seqName); $this->dropSequence($seqName);
} catch(Doctrine_Connection_Exception $e) { } catch(Doctrine_Connection_Exception $e) {
throw new Doctrine_Export_Exception('Could not drop inconsistent sequence table'); throw \Doctrine\Common\DoctrineException::updateMe('Could not drop inconsistent sequence table');
} }
} }
throw new Doctrine_Export_Exception('could not create sequence table'); throw \Doctrine\Common\DoctrineException::updateMe('could not create sequence table');
} }
/** /**
......
...@@ -172,7 +172,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager ...@@ -172,7 +172,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager
case 'rename': case 'rename':
case 'change': case 'change':
default: default:
throw new Doctrine_Export_Exception('alterTable: change type "' . $changeName . '" not yet supported'); throw \Doctrine\Common\DoctrineException::updateMe('alterTable: change type "' . $changeName . '" not yet supported');
} }
} }
......
...@@ -280,7 +280,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -280,7 +280,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
$res = $this->_conn->exec($query); $res = $this->_conn->exec($query);
} catch(Doctrine_Connection_Exception $e) { } catch(Doctrine_Connection_Exception $e) {
throw new Doctrine_Export_Exception('could not create sequence table'); throw \Doctrine\Common\DoctrineException::updateMe('could not create sequence table');
} }
if ($start == 1) { if ($start == 1) {
...@@ -296,7 +296,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -296,7 +296,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
try { try {
$res = $this->_conn->exec('DROP TABLE ' . $sequenceName); $res = $this->_conn->exec('DROP TABLE ' . $sequenceName);
} catch(Doctrine_Connection_Exception $e) { } catch(Doctrine_Connection_Exception $e) {
throw new Doctrine_Export_Exception('could not drop inconsistent sequence table'); throw \Doctrine\Common\DoctrineException::updateMe('could not drop inconsistent sequence table');
} }
return $res; return $res;
......
...@@ -43,7 +43,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -43,7 +43,7 @@ class OracleSchemaManager extends AbstractSchemaManager
public function createDatabase($name) public function createDatabase($name)
{ {
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE))
throw new Doctrine_Export_Exception('database creation is only supported if the "emulate_database" attribute is enabled'); throw \Doctrine\Common\DoctrineException::updateMe('database creation is only supported if the "emulate_database" attribute is enabled');
$username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name); $username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name);
$password = $this->conn->dsn['password'] ? $this->conn->dsn['password'] : $name; $password = $this->conn->dsn['password'] ? $this->conn->dsn['password'] : $name;
...@@ -75,7 +75,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -75,7 +75,7 @@ class OracleSchemaManager extends AbstractSchemaManager
public function dropDatabase($name) public function dropDatabase($name)
{ {
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE))
throw new Doctrine_Export_Exception('database dropping is only supported if the throw \Doctrine\Common\DoctrineException::updateMe('database dropping is only supported if the
"emulate_database" option is enabled'); "emulate_database" option is enabled');
$username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name); $username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name);
...@@ -415,7 +415,7 @@ END; ...@@ -415,7 +415,7 @@ END;
case 'rename': case 'rename':
break; break;
default: default:
throw new Doctrine_Export_Exception('change type "' . $changeName . '" not yet supported'); throw \Doctrine\Common\DoctrineException::updateMe('change type "' . $changeName . '" not yet supported');
} }
} }
...@@ -506,7 +506,7 @@ END; ...@@ -506,7 +506,7 @@ END;
public function listDatabases() public function listDatabases()
{ {
if ( ! $this->_conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) { if ( ! $this->_conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) {
throw new Doctrine_Import_Exception('database listing is only supported if the "emulate_database" option is enabled'); throw \Doctrine\Common\DoctrineException::updateMe('database listing is only supported if the "emulate_database" option is enabled');
} }
/** /**
if ($this->_conn->options['database_name_prefix']) { if ($this->_conn->options['database_name_prefix']) {
......
...@@ -267,13 +267,13 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -267,13 +267,13 @@ class SqliteSchemaManager extends AbstractSchemaManager
public function dropDatabase($databaseFile) public function dropDatabase($databaseFile)
{ {
if ( ! @file_exists($databaseFile)) { if ( ! @file_exists($databaseFile)) {
throw new Doctrine_Export_Exception('database does not exist'); throw \Doctrine\Common\DoctrineException::updateMe('database does not exist');
} }
$result = @unlink($databaseFile); $result = @unlink($databaseFile);
if ( ! $result) { if ( ! $result) {
throw new Doctrine_Export_Exception('could not remove the database file'); throw \Doctrine\Common\DoctrineException::updateMe('could not remove the database file');
} }
} }
...@@ -355,7 +355,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -355,7 +355,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
$fieldString .= ' ' . $sort; $fieldString .= ' ' . $sort;
break; break;
default: default:
throw new Doctrine_Export_Exception('Unknown index sorting option given.'); throw \Doctrine\Common\DoctrineException::updateMe('Unknown index sorting option given.');
} }
} }
} else { } else {
...@@ -434,10 +434,10 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -434,10 +434,10 @@ class SqliteSchemaManager extends AbstractSchemaManager
try { try {
$result = $db->exec('DROP TABLE ' . $sequenceName); $result = $db->exec('DROP TABLE ' . $sequenceName);
} catch(Doctrine_Connection_Exception $e) { } catch(Doctrine_Connection_Exception $e) {
throw new Doctrine_Export_Exception('could not drop inconsistent sequence table'); throw \Doctrine\Common\DoctrineException::updateMe('could not drop inconsistent sequence table');
} }
} }
throw new Doctrine_Export_Exception('could not create sequence table'); throw \Doctrine\Common\DoctrineException::updateMe('could not create sequence table');
} }
/** /**
...@@ -456,7 +456,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -456,7 +456,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
public function alterTableSql($name, array $changes, $check = false) public function alterTableSql($name, array $changes, $check = false)
{ {
if ( ! $name) { if ( ! $name) {
throw new Doctrine_Export_Exception('no valid table name specified'); throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
} }
foreach ($changes as $changeName => $change) { foreach ($changes as $changeName => $change) {
switch ($changeName) { switch ($changeName) {
...@@ -466,7 +466,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -466,7 +466,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
case 'name': case 'name':
break; break;
default: default:
throw new Doctrine_Export_Exception('change type "' . $changeName . '" not yet supported'); throw \Doctrine\Common\DoctrineException::updateMe('change type "' . $changeName . '" not yet supported');
} }
} }
......
...@@ -463,7 +463,7 @@ abstract class AbstractQuery ...@@ -463,7 +463,7 @@ abstract class AbstractQuery
} }
if ($value === null) { if ($value === null) {
throw new Doctrine_ORM_Query_Exception( 'Cannot try to set \''.$key.'\' without a value.' ); throw \Doctrine\Common\DoctrineException::updateMe( 'Cannot try to set \''.$key.'\' without a value.' );
} }
return $this->_addDqlQueryPart('set', $key . ' = ' . $value, true); return $this->_addDqlQueryPart('set', $key . ' = ' . $value, true);
...@@ -891,7 +891,7 @@ abstract class AbstractQuery ...@@ -891,7 +891,7 @@ abstract class AbstractQuery
public function getDqlQueryPart($queryPartName) public function getDqlQueryPart($queryPartName)
{ {
if ( ! isset($this->_dqlParts[$queryPartName])) { if ( ! isset($this->_dqlParts[$queryPartName])) {
throw new Doctrine_ORM_Query_Exception('Unknown DQL query part \'' . $queryPartName . '\''); throw \Doctrine\Common\DoctrineException::updateMe('Unknown DQL query part \'' . $queryPartName . '\'');
} }
return $this->_dqlParts[$queryPartName]; return $this->_dqlParts[$queryPartName];
......
...@@ -43,13 +43,13 @@ class DbCache implements Cache, \Countable ...@@ -43,13 +43,13 @@ class DbCache implements Cache, \Countable
if ( ! isset($options['connection']) || if ( ! isset($options['connection']) ||
! ($options['connection'] instanceof Doctrine_DBAL_Connection)) { ! ($options['connection'] instanceof Doctrine_DBAL_Connection)) {
throw new Doctrine_Exception('Connection option not set.'); throw \Doctrine\Common\DoctrineException::updateMe('Connection option not set.');
} }
if ( ! isset($options['tableName']) || if ( ! isset($options['tableName']) ||
! is_string($options['tableName'])) { ! is_string($options['tableName'])) {
throw new Doctrine_Exception('Table name option not set.'); throw \Doctrine\Common\DoctrineException::updateMe('Table name option not set.');
} }
$this->_options = $options; $this->_options = $options;
......
...@@ -43,7 +43,7 @@ class MemcacheCache implements Cache ...@@ -43,7 +43,7 @@ class MemcacheCache implements Cache
public function __construct() public function __construct()
{ {
if ( ! extension_loaded('memcache')) { if ( ! extension_loaded('memcache')) {
throw new Doctrine_Cache_Exception('In order to use Memcache driver, the memcache extension must be loaded.'); throw \Doctrine\Common\DoctrineException::updateMe('In order to use Memcache driver, the memcache extension must be loaded.');
} }
} }
......
...@@ -38,7 +38,7 @@ class XcacheCache implements Cache ...@@ -38,7 +38,7 @@ class XcacheCache implements Cache
public function __construct() public function __construct()
{ {
if ( ! extension_loaded('xcache')) { if ( ! extension_loaded('xcache')) {
throw new Doctrine_Exception('In order to use Xcache driver, the xcache extension must be loaded.'); throw \Doctrine\Common\DoctrineException::updateMe('In order to use Xcache driver, the xcache extension must be loaded.');
} }
} }
......
...@@ -203,7 +203,7 @@ class EntityRepository ...@@ -203,7 +203,7 @@ class EntityRepository
if (isset($by)) { if (isset($by)) {
if ( ! isset($arguments[0])) { if ( ! isset($arguments[0])) {
throw new Doctrine_Mapper_Exception('You must specify the value to findBy.'); throw \Doctrine\Common\DoctrineException::updateMe('You must specify the value to findBy.');
} }
$fieldName = Doctrine::tableize($by); $fieldName = Doctrine::tableize($by);
...@@ -214,11 +214,11 @@ class EntityRepository ...@@ -214,11 +214,11 @@ class EntityRepository
} else if ($this->_classMetadata->hasRelation($by)) { } else if ($this->_classMetadata->hasRelation($by)) {
$relation = $this->_classMetadata->getRelation($by); $relation = $this->_classMetadata->getRelation($by);
if ($relation['type'] === Doctrine_Relation::MANY) { if ($relation['type'] === Doctrine_Relation::MANY) {
throw new Doctrine_Mapper_Exception('Cannot findBy many relationship.'); throw \Doctrine\Common\DoctrineException::updateMe('Cannot findBy many relationship.');
} }
return $this->$method($relation['local'], $arguments[0], $hydrationMode); return $this->$method($relation['local'], $arguments[0], $hydrationMode);
} else { } else {
throw new Doctrine_Mapper_Exception('Cannot find by: ' . $by . '. Invalid field or relationship alias.'); throw \Doctrine\Common\DoctrineException::updateMe('Cannot find by: ' . $by . '. Invalid field or relationship alias.');
} }
} }
} }
......
...@@ -719,7 +719,7 @@ final class ClassMetadata ...@@ -719,7 +719,7 @@ final class ClassMetadata
public function getSingleIdentifierFieldName() public function getSingleIdentifierFieldName()
{ {
if ($this->_isIdentifierComposite) { if ($this->_isIdentifierComposite) {
throw new Doctrine_Exception("Calling getSingleIdentifierFieldName " throw \Doctrine\Common\DoctrineException::updateMe("Calling getSingleIdentifierFieldName "
. "on a class that uses a composite identifier is not allowed."); . "on a class that uses a composite identifier is not allowed.");
} }
return $this->_identifier[0]; return $this->_identifier[0];
......
...@@ -70,7 +70,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -70,7 +70,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister
$this->_insertRow($parentClass->getTableName(), $dataSet[$parent]); $this->_insertRow($parentClass->getTableName(), $dataSet[$parent]);
} }
} else { } else {
throw new Doctrine_Mapper_Exception("Unsupported identifier type '$identifierType'."); throw \Doctrine\Common\DoctrineException::updateMe("Unsupported identifier type '$identifierType'.");
} }
$entity->_assignIdentifier($identifier); $entity->_assignIdentifier($identifier);
} else { } else {
...@@ -243,7 +243,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -243,7 +243,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister
} }
} }
throw new Doctrine_Mapper_Exception("Unable to find defining class of field '$fieldName'."); throw \Doctrine\Common\DoctrineException::updateMe("Unable to find defining class of field '$fieldName'.");
}*/ }*/
/** /**
......
...@@ -91,7 +91,7 @@ class StandardEntityPersister extends AbstractEntityPersister ...@@ -91,7 +91,7 @@ class StandardEntityPersister extends AbstractEntityPersister
$id = $conn->sequence->lastInsertId($seq); $id = $conn->sequence->lastInsertId($seq);
if ( ! $id) { if ( ! $id) {
throw new Doctrine_Mapper_Exception("Couldn't get last insert identifier."); throw \Doctrine\Common\DoctrineException::updateMe("Couldn't get last insert identifier.");
} }
$record->assignIdentifier($id); $record->assignIdentifier($id);
......
...@@ -198,7 +198,7 @@ abstract class AbstractResult ...@@ -198,7 +198,7 @@ abstract class AbstractResult
public function getTableAlias($tableAlias) public function getTableAlias($tableAlias)
{ {
if ( ! isset($this->_tableAliasMap[$tableAlias])) { if ( ! isset($this->_tableAliasMap[$tableAlias])) {
throw new Doctrine_ORM_Query_Exception('Unknown table alias ' . $tableAlias); throw \Doctrine\Common\DoctrineException::updateMe('Unknown table alias ' . $tableAlias);
} }
return $this->_tableAliasMap[$tableAlias]; return $this->_tableAliasMap[$tableAlias];
......
...@@ -131,7 +131,7 @@ class ParserResult extends AbstractResult ...@@ -131,7 +131,7 @@ class ParserResult extends AbstractResult
public function getQueryField($fieldAlias) public function getQueryField($fieldAlias)
{ {
if ( ! isset($this->_queryFields[$fieldAlias])) { if ( ! isset($this->_queryFields[$fieldAlias])) {
throw new Doctrine_ORM_Query_Exception('Unknown query field ' . $fieldAlias); throw \Doctrine\Common\DoctrineException::updateMe('Unknown query field ' . $fieldAlias);
} }
return $this->_queryFields[$fieldAlias]; return $this->_queryFields[$fieldAlias];
......
...@@ -157,7 +157,7 @@ abstract class ParserRule ...@@ -157,7 +157,7 @@ abstract class ParserRule
//TODO: This expensive check is not necessary. Should be removed at the end. //TODO: This expensive check is not necessary. Should be removed at the end.
// "new $class" will throw an error anyway if the class is not found. // "new $class" will throw an error anyway if the class is not found.
if ( ! class_exists($class)) { if ( ! class_exists($class)) {
throw new Doctrine_ORM_Query_Parser_Exception( throw \Doctrine\Common\DoctrineException::updateMe(
"Unknown Grammar Rule '$name'. Could not find related compiler class." "Unknown Grammar Rule '$name'. Could not find related compiler class."
); );
} }
......
...@@ -21,8 +21,9 @@ class AllTests ...@@ -21,8 +21,9 @@ class AllTests
{ {
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Common Tests'); $suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Common Tests');
$suite->addTestSuite('Doctrine\Tests\Common\EventManagerTest'); $suite->addTestSuite('Doctrine\Tests\Common\DoctrineExceptionTest');
$suite->addTestSuite('Doctrine\Tests\Common\ClassLoaderTest'); $suite->addTestSuite('Doctrine\Tests\Common\ClassLoaderTest');
$suite->addTestSuite('Doctrine\Tests\Common\EventManagerTest');
$suite->addTest(Collections\AllTests::suite()); $suite->addTest(Collections\AllTests::suite());
......
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