Skip to content

Commit

Permalink
Adding MissingModelException.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 28, 2010
1 parent caf7668 commit b301b0d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cake/libs/controller/controller.php
Expand Up @@ -572,6 +572,7 @@ public function httpCodes($code = null) {
* @param string $modelClass Name of model class to load
* @param mixed $id Initial ID the instanced model class should have
* @return mixed true when single model found and instance created, error returned if model not found.
* @throws MissingModelException if the model class cannot be found.
*/
public function loadModel($modelClass = null, $id = null) {
if ($modelClass === null) {
Expand All @@ -593,9 +594,7 @@ public function loadModel($modelClass = null, $id = null) {
));

if (!$this->{$modelClass}) {
return $this->cakeError('missingModel', array(array(
'className' => $modelClass, 'webroot' => '', 'base' => $this->base
)));
throw new MissingModelException($modelClass);
}

if ($this->persistModel === true) {
Expand Down Expand Up @@ -1252,3 +1251,5 @@ public function _scaffoldError($method) {
return false;
}
}

class MissingModelException extends RuntimeException {}

0 comments on commit b301b0d

Please sign in to comment.