Commit 261b71d2 authored by catch's avatar catch

Issue #1992950 by xjm: Stop use-ing Exception.

parent b18ad406
......@@ -42,8 +42,6 @@
namespace Drupal\Component\Archiver;
use Exception;
//require_once 'PEAR.php';
//
//
......@@ -636,7 +634,7 @@ function _error($p_message)
{
// ----- To be completed
// $this->raiseError($p_message);
throw new Exception($p_message);
throw new \Exception($p_message);
}
// }}}
......@@ -645,7 +643,7 @@ function _warning($p_message)
{
// ----- To be completed
// $this->raiseError($p_message);
throw new Exception($p_message);
throw new \Exception($p_message);
}
// }}}
......
......@@ -7,10 +7,8 @@
namespace Drupal\Component\Archiver;
use Exception;
/**
* Defines an exception class for Drupal\Component\Archiver\ArchiverInterface.
*/
class ArchiverException extends Exception {
}
class ArchiverException extends \Exception {}
......@@ -7,9 +7,7 @@
namespace Drupal\Component\Plugin\Exception;
use Exception;
/**
* An exception class to be thrown for context plugin exceptions.
*/
class ContextException extends Exception implements ExceptionInterface { }
class ContextException extends \Exception implements ExceptionInterface { }
......@@ -6,10 +6,8 @@
namespace Drupal\Component\Plugin\Exception;
use Exception;
/**
* Generic Plugin exception class to be thrown when no more specific class
* is applicable.
*/
class PluginException extends Exception implements ExceptionInterface { }
class PluginException extends \Exception implements ExceptionInterface { }
......@@ -9,7 +9,6 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Connection;
use Exception;
/**
* Defines the Database storage controller.
......@@ -81,7 +80,7 @@ public function read($name) {
$data = $this->decode($raw);
}
}
catch (Exception $e) {
catch (\Exception $e) {
}
return $data;
}
......
......@@ -13,8 +13,6 @@
use Drupal\Core\Database\SchemaObjectDoesNotExistException;
use Drupal\Core\Database\Schema as DatabaseSchema;
use Exception;
/**
* @addtogroup schemaapi
* @{
......@@ -516,7 +514,7 @@ public function tableExists($table) {
$this->connection->queryRange("SELECT 1 FROM {" . $table . "}", 0, 1);
return TRUE;
}
catch (Exception $e) {
catch (\Exception $e) {
return FALSE;
}
}
......@@ -533,7 +531,7 @@ public function fieldExists($table, $column) {
$this->connection->queryRange("SELECT $column FROM {" . $table . "}", 0, 1);
return TRUE;
}
catch (Exception $e) {
catch (\Exception $e) {
return FALSE;
}
}
......
......@@ -12,8 +12,6 @@
use Drupal\Core\Database\Driver\pgsql\Connection;
use Drupal\Core\Database\DatabaseNotFoundException;
use Exception;
/**
* PostgreSQL specific install functions
*/
......@@ -55,7 +53,7 @@ protected function connect() {
Database::getConnection();
$this->pass('Drupal can CONNECT to the database ok.');
}
catch (Exception $e) {
catch (\Exception $e) {
// Attempt to create the database if it is not found.
if ($e->getCode() == Connection::DATABASE_NOT_FOUND) {
// Remove the database string from connection info.
......@@ -118,7 +116,7 @@ protected function checkEncoding() {
$this->fail(st($text, $replacements));
}
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(st('Drupal could not determine the encoding of the database was set to UTF-8'));
}
}
......@@ -145,7 +143,7 @@ function checkBinaryOutput() {
try {
db_query($query);
}
catch (Exception $e) {
catch (\Exception $e) {
// Ignore possible errors when the user doesn't have the necessary
// privileges to ALTER the database.
}
......@@ -233,7 +231,7 @@ function initializeDatabase() {
$this->pass(st('PostgreSQL has initialized itself.'));
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(st('Drupal could not be correctly setup with the existing database. Revise any errors.'));
}
}
......
......@@ -13,8 +13,6 @@
use Drupal\Core\Database\SchemaObjectDoesNotExistException;
use Drupal\Core\Database\Schema as DatabaseSchema;
use Exception;
/**
* @addtogroup schemaapi
* @{
......
......@@ -16,7 +16,6 @@
use Drupal\Core\Database\Connection as DatabaseConnection;
use PDO;
use Exception;
use SplFileInfo;
/**
......@@ -161,7 +160,7 @@ public function __destruct() {
unlink($this->connectionOptions['database'] . '-' . $prefix);
}
}
catch (Exception $e) {
catch (\Exception $e) {
// Ignore the exception and continue. There is nothing we can do here
// to report the error or fail safe.
}
......
......@@ -12,8 +12,6 @@
use Drupal\Core\Database\DatabaseNotFoundException;
use Drupal\Core\Database\Install\Tasks as InstallTasks;
use Exception;
class Tasks extends InstallTasks {
protected $pdoDriver = 'sqlite';
......@@ -56,7 +54,7 @@ protected function connect() {
Database::getConnection();
$this->pass('Drupal can CONNECT to the database ok.');
}
catch (Exception $e) {
catch (\Exception $e) {
// Attempt to create the database if it is not found.
if ($e->getCode() == Connection::DATABASE_NOT_FOUND) {
// Remove the database string from connection info.
......
......@@ -11,9 +11,6 @@
use Drupal\Core\Database\SchemaObjectDoesNotExistException;
use Drupal\Core\Database\Schema as DatabaseSchema;
use Exception;
/**
* @ingroup schemaapi
* @{
......@@ -451,7 +448,7 @@ protected function introspectSchema($table) {
}
}
else {
new Exception("Unable to parse the column type " . $row->type);
new \Exception("Unable to parse the column type " . $row->type);
}
}
$indexes = array();
......
......@@ -10,7 +10,6 @@
use Drupal\Core\Database\Database;
use PDO;
use Exception;
/**
* Database installer structure.
......@@ -166,7 +165,7 @@ protected function connect() {
Database::getConnection();
$this->pass('Drupal can CONNECT to the database ok.');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
return FALSE;
}
......@@ -181,7 +180,7 @@ protected function runTestQuery($query, $pass, $fail, $fatal = FALSE) {
db_query($query);
$this->pass(st($pass));
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(st($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name())));
return !$fatal;
}
......
......@@ -9,8 +9,6 @@
use Drupal\Core\Database\Database;
use Exception;
/**
* General class for an abstracted INSERT query.
*/
......@@ -220,7 +218,7 @@ public function execute() {
$last_insert_id = $this->connection->query($sql, $insert_values, $this->queryOptions);
}
}
catch (Exception $e) {
catch (\Exception $e) {
// One of the INSERTs failed, rollback the whole batch.
$transaction->rollback();
// Rethrow the exception for the calling code.
......
......@@ -7,9 +7,7 @@
namespace Drupal\Core\Entity;
use Exception;
/**
* Defines an exception thrown when a malformed entity is passed.
*/
class EntityMalformedException extends Exception { }
class EntityMalformedException extends \Exception { }
......@@ -7,9 +7,7 @@
namespace Drupal\Core\Entity;
use Exception;
/**
* Defines an exception thrown when storage operations fail.
*/
class EntityStorageException extends Exception { }
class EntityStorageException extends \Exception { }
......@@ -6,11 +6,9 @@
namespace Drupal\Core\Executable;
use Exception;
use Drupal\Component\Plugin\Exception\ExceptionInterface;
/**
* Generic executable plugin exception class.
*/
class ExecutableException extends Exception implements ExceptionInterface {
}
class ExecutableException extends \Exception implements ExceptionInterface {}
......@@ -7,11 +7,7 @@
namespace Drupal\Core\TypedData;
use Exception;
/**
* Exception thrown when data wrappers miss contextual information.
*/
class MissingContextException extends Exception {
}
class MissingContextException extends \Exception {}
......@@ -7,11 +7,7 @@
namespace Drupal\Core\TypedData;
use Exception;
/**
* Exception thrown when trying to write or set ready-only data.
*/
class ReadOnlyException extends Exception {
}
class ReadOnlyException extends \Exception {}
......@@ -7,8 +7,6 @@
namespace Drupal\Core\Updater;
use Exception;
/**
* Defines a Exception class for the Drupal\Core\Updater\Updater class
* hierarchy.
......@@ -17,5 +15,4 @@
* specific name so that call sites that want to tell the difference can
* specifically catch these exceptions and treat them differently.
*/
class UpdaterException extends Exception {
}
class UpdaterException extends \Exception {}
......@@ -7,9 +7,7 @@
namespace Drupal\Core\Utility;
use Exception;
/**
* Exception class used to throw error if a module update fails.
*/
class UpdateException extends Exception { }
class UpdateException extends \Exception { }
......@@ -8,7 +8,6 @@
namespace Drupal\field\Tests;
use Drupal\field\FieldException;
use Exception;
class CrudTest extends FieldUnitTestBase {
......@@ -168,7 +167,7 @@ function testCreateFieldFail() {
$field = field_create_field($field_definition);
$this->assertTrue(FALSE, 'Field creation (correctly) fails.');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->assertTrue(TRUE, 'Field creation (correctly) fails.');
}
......
......@@ -10,7 +10,6 @@
use Drupal\Core\Database\Database;
use Drupal\field\FieldException;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Exception;
use PDO;
/**
......@@ -339,7 +338,7 @@ function testFieldUpdateFailure() {
field_update_field($field);
$this->fail(t('Update succeeded.'));
}
catch (Exception $e) {
catch (\Exception $e) {
$this->pass(t('Update properly failed.'));
}
......
......@@ -10,7 +10,6 @@
use Drupal\Component\Gettext\PoStreamReader;
use Drupal\Component\Gettext\PoMemoryWriter;
use Drupal\locale\PoDatabaseWriter;
use Exception;
/**
* Static class providing Drupal specific Gettext functionality.
......@@ -89,13 +88,13 @@ static function fileToDatabase($file, $options) {
try {
$reader->open();
}
catch (Exception $exception) {
catch (\Exception $exception) {
throw $exception;
}
$header = $reader->getHeader();
if (!$header) {
throw new Exception('Missing or malformed header.');
throw new \Exception('Missing or malformed header.');
}
// Initialize the database writer.
......@@ -115,7 +114,7 @@ static function fileToDatabase($file, $options) {
}
$writer->writeItems($reader, $options['items']);
}
catch (Exception $exception) {
catch (\Exception $exception) {
throw $exception;
}
......
......@@ -7,9 +7,7 @@
namespace Drupal\locale;
use Exception;
/**
* Defines an exception thrown when storage operations fail.
*/
class StringStorageException extends Exception { }
class StringStorageException extends \Exception { }
......@@ -8,7 +8,6 @@
namespace Drupal\node\Tests;
use Drupal\Core\Database\Database;
use Exception;
/**
* Tests creating and saving a node.
......@@ -75,7 +74,7 @@ function testFailedPageCreation() {
entity_create('node', $edit)->save();
$this->fail(t('Expected exception has not been thrown.'));
}
catch (Exception $e) {
catch (\Exception $e) {
$this->pass(t('Expected exception has been thrown.'));
}
......
......@@ -7,8 +7,6 @@
namespace Drupal\node\Tests;
use Exception;
/**
* Tests node_query_node_access_alter().
*/
......@@ -100,7 +98,7 @@ function testNodeQueryAlterLowLevelWithAccess() {
$result = $query->execute()->fetchAll();
$this->assertEqual(count($result), 4, 'User with access can see correct nodes');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(t('Altered query is malformed'));
}
}
......@@ -123,7 +121,7 @@ function testNodeQueryAlterLowLevelNoAccess() {
$result = $query->execute()->fetchAll();
$this->assertEqual(count($result), 0, 'User with no access cannot see nodes');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(t('Altered query is malformed'));
}
}
......@@ -146,7 +144,7 @@ function testNodeQueryAlterLowLevelEditAccess() {
$result = $query->execute()->fetchAll();
$this->assertEqual(count($result), 0, 'User with view-only access cannot edit nodes');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail($e->getMessage());
$this->fail((string) $query);
$this->fail(t('Altered query is malformed'));
......@@ -186,7 +184,7 @@ function testNodeQueryAlterOverride() {
$result = $query->execute()->fetchAll();
$this->assertEqual(count($result), 0, 'User view privileges are not overridden');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(t('Altered query is malformed'));
}
......@@ -208,7 +206,7 @@ function testNodeQueryAlterOverride() {
$result = $query->execute()->fetchAll();
$this->assertEqual(count($result), 4, 'User view privileges are overridden');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail(t('Altered query is malformed'));
}
state()->delete('node_access_test.no_access_uid');
......
......@@ -14,7 +14,6 @@
use Drupal\Core\DrupalKernel;
use ReflectionMethod;
use ReflectionObject;
use Exception;
/**
* Base class for Drupal tests.
......@@ -733,7 +732,7 @@ public function run(array $methods = array()) {
$this->$method();
// Finish up.
}
catch (Exception $e) {
catch (\Exception $e) {
$this->exceptionHandler($e);
}
$this->tearDown();
......
......@@ -8,7 +8,6 @@
namespace Drupal\system\Tests\Database;
use Drupal\Core\Database\IntegrityConstraintViolationException;
use Exception;
/**
* Tests invalid data handling.
......
......@@ -10,8 +10,6 @@
use Drupal\Core\Database\Database;
use Drupal\simpletest\UnitTestBase;
use Exception;
/**
* Tests the Schema API.
*/
......@@ -141,7 +139,7 @@ function testSchema() {
try {
db_create_table('test_timestamp', $table_specification);
}
catch (Exception $e) {}
catch (\Exception $e) {}
$this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.');
}
......@@ -161,7 +159,7 @@ function tryInsert($table = 'test_table') {
->execute();
return TRUE;
}
catch (Exception $e) {
catch (\Exception $e) {
return FALSE;
}
}
......@@ -233,7 +231,7 @@ function tryUnsignedInsert($table_name, $column_name) {
->execute();
return TRUE;
}
catch (Exception $e) {
catch (\Exception $e) {
return FALSE;
}
}
......
......@@ -10,7 +10,6 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Database\TransactionOutOfOrderException;
use Drupal\Core\Database\TransactionNoActiveException;
use Exception;
/**
* Tests transaction support, particularly nesting.
......@@ -176,7 +175,7 @@ function testTransactionRollBackSupported() {
$saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField();
$this->assertNotIdentical($saved_age, '19', 'Cannot retrieve DanielB row after commit.');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
......@@ -202,7 +201,7 @@ function testTransactionRollBackNotSupported() {
$saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField();
$this->assertIdentical($saved_age, '19', 'DanielB not rolled back, since transactions are not supported.');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
......@@ -224,7 +223,7 @@ function testCommittedTransaction() {
$saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielA'))->fetchField();
$this->assertIdentical($saved_age, '19', 'Can retrieve DanielA row after commit.');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
......
......@@ -7,8 +7,6 @@
namespace Drupal\system\Tests\Entity;
use Exception;
use InvalidArgumentException;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Language\Language;
......
......@@ -8,7 +8,6 @@
namespace Drupal\system\Tests\Plugin;
use Drupal\Component\Plugin\Exception\ExceptionInterface;
use Exception;
use Drupal\plugin_test\Plugin\AlterDecoratorTestPluginManager;
use Drupal\plugin_test\Plugin\TestPluginManager;
use Drupal\simpletest\WebTestBase;
......
......@@ -8,7 +8,6 @@
namespace Drupal\system\Tests\Plugin;
use Drupal\Component\Plugin\Exception\ExceptionInterface;
use Exception;
/**
* Tests that plugins are correctly instantiated.
......@@ -41,7 +40,7 @@ function testDefaultFactory() {
catch (ExceptionInterface $e) {
$this->pass('Drupal\Component\Plugin\Exception\ExceptionInterface expected and caught.');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail('Drupal\Component\Plugin\Exception\ExceptionInterface expected, but ' . get_class($e) . ' was thrown.');
}
}
......@@ -78,7 +77,7 @@ function testReflectionFactory() {
catch (ExceptionInterface $e) {
$this->pass('Drupal\Component\Plugin\Exception\ExceptionInterface expected and caught.');
}
catch (Exception $e) {
catch (\Exception $e) {
$this->fail('An unexpected Exception of type "' . get_class($e) . '" was thrown with message ' . $e->getMessage());
}
}
......
......@@ -18,8 +18,6 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Routing\MatcherDumper;
use Exception;
/**
* Basic tests for the RouteProvider.
*/
......@@ -329,7 +327,7 @@ function testOutlinePathNoMatch() {
$routes = $provider->getRouteCollectionForRequest($request);
$this->fail(t('No exception was thrown.'));
}
catch (Exception $e) {
catch (\Exception $e) {
$this->assertTrue($e instanceof ResourceNotFoundException, 'The correct exception was thrown.');
}
}
......
......@@ -10,7 +10,6 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Database\Database;
use Drupal\simpletest\WebTestBase;
use Exception;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\HttpFoundation\Request;
......@@ -188,7 +187,7 @@ protected function variable_set($name, $value) {
}
// Since cache_bootstrap won't exist in a Drupal 6 site, ignore the
// exception if the above fails.
catch (Exception $e) {}
catch (\Exception $e) {}
}
/**
......@@ -220,12 +219,12 @@ protected function performUpgrade($register_errors = TRUE) {
// Load the first update screen.
$this->getUpdatePhp();
if (!$this->assertResponse(200)) {
throw new Exception('Initial GET to update.php did not return HTTP 200 status.');
throw new \Exception('Initial GET to update.php did not return HTTP 200 status.');
}
// Ensure that the first update screen appeared correctly.
if (!$this->assertFieldByXPath('//input[@type="submit"]')) {
throw new Exception('An error was encountered during the first access to update.php.');
throw new \Exception('An error was encountered during the first access to update.php.');
}
// Initialize config directories and rebuild the service container after
......@@ -236,7 +235,7 @@ protected function performUpgrade($register_errors = TRUE) {
// Continue.
$this->drupalPost(NULL, array(), t('Continue'));
if (!$this->assertResponse(200)) {
throw new Exception('POST to continue update.php did not return HTTP 200 status.');
throw new \Exception('POST to continue update.php did not return HTTP 200 status.');
}
// The test should pass if there are no pending updates.
......@@ -250,12 +249,12 @@ protected function performUpgrade($register_errors = TRUE) {
// Go!
$this->drupalPost(NULL, array(), t('Apply pending updates'));
if (!$this->assertResponse(200)) {
throw new Exception('POST to update.php to apply pending updates did not return HTTP 200 status.');
throw new \Exception('POST to update.php to apply pending updates did not return HTTP 200 status.');
}
if (!$this->assertNoText(t('An unrecoverable error has occurred.'))) {
// Error occured during update process.
throw new Exception('POST to update.php to apply pending updates detected an unrecoverable error.');
throw new \Exception('POST to update.php to apply pending updates detected an unrecoverable error.');
}
// Check for errors during the update process.
......@@ -269,7 +268,7 @@ protected function performUpgrade($register_errors = TRUE) {
if (!empty($this->upgradeErrors)) {
// Upgrade failed, the installation might be in an inconsistent state,
// don't process.