From b301b0d86e87f190a3cf4638de2024b67fb4a6ed Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 27 Aug 2010 23:04:35 -0400 Subject: [PATCH] Adding MissingModelException. --- cake/libs/controller/controller.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 7405bfb4136..93bb4fb6fbd 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -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) { @@ -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) { @@ -1252,3 +1251,5 @@ public function _scaffoldError($method) { return false; } } + +class MissingModelException extends RuntimeException {}