Browse Source

Model\Error -> Model\Exception

Jose Lorenzo Rodriguez 11 years ago
parent
commit
a5571df128

+ 1 - 1
src/Model/Error/MissingModelException.php

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

+ 6 - 5
src/Model/ModelAwareTrait.php

@@ -14,7 +14,8 @@
  */
 namespace Cake\Model;
 
-use Cake\Core\Exception\Exception;
+use Cake\Model\Exception\MissingModelException;
+use InvalidArgumentException;
 
 /**
  * Provides functionality for loading table classes
@@ -71,8 +72,8 @@ trait ModelAwareTrait {
  * @param string $type The type of repository to load. Defaults to 'Table' which
  *   delegates to Cake\ORM\TableRegistry.
  * @return bool True when single repository found and instance created.
- * @throws \Cake\Model\Error\MissingModelException If the model class cannot be found.
- * @throws \Cake\Core\Exception\Exception When using a type that has not been registered.
+ * @throws \Cake\Model\Exception\MissingModelException If the model class cannot be found.
+ * @throws \InvalidArgumentException When using a type that has not been registered.
  */
 	public function loadModel($modelClass = null, $type = 'Table') {
 		if ($modelClass === null) {
@@ -86,7 +87,7 @@ trait ModelAwareTrait {
 		list($plugin, $modelClass) = pluginSplit($modelClass, true);
 
 		if (!isset($this->_modelFactories[$type])) {
-			throw new Exception(sprintf(
+			throw new InvalidArgumentException(sprintf(
 				'Unknown repository type "%s". Make sure you register a type before trying to use it.',
 				$type
 			));
@@ -94,7 +95,7 @@ trait ModelAwareTrait {
 		$factory = $this->_modelFactories[$type];
 		$this->{$modelClass} = $factory($plugin . $modelClass);
 		if (!$this->{$modelClass}) {
-			throw new Error\MissingModelException([$modelClass, $type]);
+			throw new MissingModelException([$modelClass, $type]);
 		}
 		return true;
 	}

+ 1 - 1
tests/TestCase/Model/ModelAwareTraitTest.php

@@ -89,7 +89,7 @@ class ModelAwareTraitTest extends TestCase {
  * test MissingModelException being thrown
  *
  * @return void
- * @expectedException Cake\Model\Error\MissingModelException
+ * @expectedException Cake\Model\Exception\MissingModelException
  * @expectedExceptionMessage Model class "Magic" of type "Test" could not be found.
  */
 	public function testMissingModelException() {