Skip to content

Commit

Permalink
Model\Error -> Model\Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Aug 30, 2014
1 parent 3f6ffe3 commit a5571df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 6 additions & 5 deletions src/Model/ModelAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,8 +72,8 @@ protected function _setModelClass($name) {
* @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) {
Expand All @@ -86,15 +87,15 @@ public function loadModel($modelClass = null, $type = 'Table') {
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
));
}
$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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Model/ModelAwareTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testModelFactory() {
* 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() {
Expand Down

0 comments on commit a5571df

Please sign in to comment.