Browse Source

Database\Error -> Database\Exception

Jose Lorenzo Rodriguez 11 years ago
parent
commit
3f6ffe33dd

+ 9 - 6
src/Database/Connection.php

@@ -14,6 +14,9 @@
  */
 namespace Cake\Database;
 
+use Cake\Database\Exception\MissingConnectionException;
+use Cake\Database\Exception\MissingDriverException;
+use Cake\Database\Exception\MissingExtensionException;
 use Cake\Database\Log\LoggedQuery;
 use Cake\Database\Log\LoggingStatement;
 use Cake\Database\Log\QueryLogger;
@@ -135,8 +138,8 @@ class Connection {
  *
  * @param string|\Cake\Database\Driver $driver The driver instance to use.
  * @param array|null $config Either config for a new driver or null.
- * @throws \Cake\Database\Error\MissingDriverException When a driver class is missing.
- * @throws \Cake\Database\Error\MissingExtensionException When a driver's PHP extension is missing.
+ * @throws \Cake\Database\Exception\MissingDriverException When a driver class is missing.
+ * @throws \Cake\Database\Exception\MissingExtensionException When a driver's PHP extension is missing.
  * @return \Cake\Database\Driver
  */
 	public function driver($driver = null, $config = null) {
@@ -145,12 +148,12 @@ class Connection {
 		}
 		if (is_string($driver)) {
 			if (!class_exists($driver)) {
-				throw new Error\MissingDriverException(['driver' => $driver]);
+				throw new MissingDriverException(['driver' => $driver]);
 			}
 			$driver = new $driver($config);
 		}
 		if (!$driver->enabled()) {
-			throw new Error\MissingExtensionException(['driver' => get_class($driver)]);
+			throw new MissingExtensionException(['driver' => get_class($driver)]);
 		}
 		return $this->_driver = $driver;
 	}
@@ -158,7 +161,7 @@ class Connection {
 /**
  * Connects to the configured database.
  *
- * @throws \Cake\Database\Error\MissingConnectionException if credentials are invalid
+ * @throws \Cake\Database\Exception\MissingConnectionException if credentials are invalid
  * @return bool true on success or false if already connected.
  */
 	public function connect() {
@@ -166,7 +169,7 @@ class Connection {
 			$this->_driver->connect();
 			return true;
 		} catch(\Exception $e) {
-			throw new Error\MissingConnectionException(['reason' => $e->getMessage()]);
+			throw new MissingConnectionException(['reason' => $e->getMessage()]);
 		}
 	}
 

+ 1 - 1
src/Database/Error/MissingConnectionException.php

@@ -12,7 +12,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Database\Error;
+namespace Cake\Database\Exception;
 
 use Cake\Core\Exception\Exception;
 

+ 1 - 1
src/Database/Error/MissingDriverException.php

@@ -12,7 +12,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Database\Error;
+namespace Cake\Database\Exception;
 
 use Cake\Core\Exception\Exception;
 

+ 1 - 1
src/Database/Error/MissingExtensionException.php

@@ -12,7 +12,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Database\Error;
+namespace Cake\Database\Exception;
 
 use Cake\Core\Exception\Exception;
 

+ 5 - 5
tests/TestCase/Database/ConnectionTest.php

@@ -64,7 +64,7 @@ class ConnectionTest extends TestCase {
 /**
  * Tests creating a connection using no driver throws an exception
  *
- * @expectedException \Cake\Database\Error\MissingDriverException
+ * @expectedException \Cake\Database\Exception\MissingDriverException
  * @expectedExceptionMessage Database driver  could not be found.
  * @return void
  */
@@ -75,7 +75,7 @@ class ConnectionTest extends TestCase {
 /**
  * Tests creating a connection using an invalid driver throws an exception
  *
- * @expectedException \Cake\Database\Error\MissingDriverException
+ * @expectedException \Cake\Database\Exception\MissingDriverException
  * @expectedExceptionMessage Database driver  could not be found.
  * @return void
  */
@@ -86,7 +86,7 @@ class ConnectionTest extends TestCase {
 /**
  * Tests creating a connection using an invalid driver throws an exception
  *
- * @expectedException \Cake\Database\Error\MissingDriverException
+ * @expectedException \Cake\Database\Exception\MissingDriverException
  * @expectedExceptionMessage Database driver \Foo\InvalidDriver could not be found.
  * @return void
  */
@@ -97,7 +97,7 @@ class ConnectionTest extends TestCase {
 /**
  * Tests trying to use a disabled driver throws an exception
  *
- * @expectedException \Cake\Database\Error\MissingExtensionException
+ * @expectedException \Cake\Database\Exception\MissingExtensionException
  * @expectedExceptionMessage Database driver DriverMock cannot be used due to a missing PHP extension or unmet dependency
  * @return void
  */
@@ -109,7 +109,7 @@ class ConnectionTest extends TestCase {
 /**
  * Tests that connecting with invalid credentials or database name throws an exception
  *
- * @expectedException \Cake\Database\Error\MissingConnectionException
+ * @expectedException \Cake\Database\Exception\MissingConnectionException
  * @return void
  */
 	public function testWrongCredentials() {