|
|
@@ -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;
|
|
|
}
|