Browse Source

Controller\Error -> Controller\Exception

Also moved MissingControllerException to Router, as it has a better home there
Jose Lorenzo Rodriguez 11 years ago
parent
commit
22f90f767c

+ 4 - 3
src/Controller/ComponentRegistry.php

@@ -14,9 +14,10 @@
  */
 namespace Cake\Controller;
 
+use Cake\Controller\Exception\MissingComponentException;
 use Cake\Core\App;
-use Cake\Event\EventManagerTrait;
 use Cake\Core\ObjectRegistry;
+use Cake\Event\EventManagerTrait;
 
 /**
  * ComponentRegistry is a registry for loaded components
@@ -75,10 +76,10 @@ class ComponentRegistry extends ObjectRegistry {
  * @param string $class The classname that is missing.
  * @param string $plugin The plugin the component is missing in.
  * @return void
- * @throws \Cake\Controller\Error\MissingComponentException
+ * @throws \Cake\Controller\Exception\MissingComponentException
  */
 	protected function _throwMissingClassError($class, $plugin) {
-		throw new Error\MissingComponentException([
+		throw new MissingComponentException([
 			'class' => $class . 'Component',
 			'plugin' => $plugin
 		]);

+ 6 - 5
src/Controller/Controller.php

@@ -14,7 +14,8 @@
  */
 namespace Cake\Controller;
 
-use Cake\Core\Exception\Exception;
+use Cake\Controller\Exception\MissingActionException;
+use Cake\Controller\Exception\PrivateActionException;
 use Cake\Event\Event;
 use Cake\Event\EventListener;
 use Cake\Event\EventManagerTrait;
@@ -352,8 +353,8 @@ class Controller implements EventListener {
  *
  * @return mixed The resulting response.
  * @throws \LogicException When request is not set.
- * @throws \Cake\Controller\Error\PrivateActionException When actions are not public or prefixed by _
- * @throws \Cake\Controller\Error\MissingActionException When actions are not defined.
+ * @throws \Cake\Controller\Exception\PrivateActionException When actions are not public or prefixed by _
+ * @throws \Cake\Controller\Exception\MissingActionException When actions are not defined.
  */
 	public function invokeAction() {
 		try {
@@ -363,7 +364,7 @@ class Controller implements EventListener {
 			}
 			$method = new \ReflectionMethod($this, $request->params['action']);
 			if ($this->_isPrivateAction($method, $request)) {
-				throw new Error\PrivateActionException(array(
+				throw new PrivateActionException(array(
 					'controller' => $this->name . "Controller",
 					'action' => $request->params['action'],
 					'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '',
@@ -373,7 +374,7 @@ class Controller implements EventListener {
 			return $method->invokeArgs($this, $request->params['pass']);
 
 		} catch (\ReflectionException $e) {
-			throw new Error\MissingActionException(array(
+			throw new MissingActionException(array(
 				'controller' => $this->name . "Controller",
 				'action' => $request->params['action'],
 				'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '',

+ 1 - 1
src/Controller/Error/MissingActionException.php

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

+ 1 - 1
src/Controller/Error/MissingComponentException.php

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

+ 1 - 1
src/Controller/Error/PrivateActionException.php

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

+ 5 - 5
src/Routing/Dispatcher.php

@@ -15,13 +15,13 @@
 namespace Cake\Routing;
 
 use Cake\Controller\Controller;
-use Cake\Controller\Error\MissingControllerException;
-use Cake\Core\Exception\Exception;
 use Cake\Event\Event;
 use Cake\Event\EventListener;
 use Cake\Event\EventManagerTrait;
 use Cake\Network\Request;
 use Cake\Network\Response;
+use Cake\Routing\Error\MissingControllerException;
+use LogicException;
 
 /**
  * Dispatcher converts Requests into controller actions. It uses the dispatched Request
@@ -55,7 +55,7 @@ class Dispatcher {
  * @param \Cake\Network\Request $request Request object to dispatch.
  * @param \Cake\Network\Response $response Response object to put the results of the dispatch into.
  * @return string|void if `$request['return']` is set then it returns response body, null otherwise
- * @throws \Cake\Controller\Error\MissingControllerException When the controller is missing.
+ * @throws \Cake\Routing\Error\MissingControllerException When the controller is missing.
  */
 	public function dispatch(Request $request, Response $response) {
 		$beforeEvent = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response'));
@@ -102,7 +102,7 @@ class Dispatcher {
  *
  * @param Controller $controller Controller to invoke
  * @return \Cake\Network\Response The resulting response object
- * @throws \Cake\Core\Exception\Exception If data returned by controller action is not an
+ * @throws \LogicException If data returned by controller action is not an
  *   instance of Response
  */
 	protected function _invoke(Controller $controller) {
@@ -114,7 +114,7 @@ class Dispatcher {
 
 		$response = $controller->invokeAction();
 		if ($response !== null && !($response instanceof Response)) {
-			throw new Exception('Controller action can only return an instance of Response');
+			throw new LogicException('Controller action can only return an instance of Response');
 		}
 
 		if (!$response && $controller->autoRender) {

+ 1 - 1
src/Controller/Error/MissingControllerException.php

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

+ 1 - 1
tests/TestCase/Console/ConsoleErrorHandlerTest.php

@@ -15,7 +15,7 @@
 namespace Cake\Test\TestCase\Console;
 
 use Cake\Console\ConsoleErrorHandler;
-use Cake\Controller\Error\MissingActionException;
+use Cake\Controller\Exception\MissingActionException;
 use Cake\Core\Exception\Exception;
 use Cake\Log\Log;
 use Cake\Network\Exception\InternalErrorException;

+ 1 - 1
tests/TestCase/Controller/ComponentRegistryTest.php

@@ -116,7 +116,7 @@ class ComponentRegistryTest extends TestCase {
 /**
  * test missingcomponent exception
  *
- * @expectedException \Cake\Controller\Error\MissingComponentException
+ * @expectedException \Cake\Controller\Exception\MissingComponentException
  * @return void
  */
 	public function testLoadMissingComponent() {

+ 5 - 5
tests/TestCase/Controller/ControllerTest.php

@@ -722,7 +722,7 @@ class ControllerTest extends TestCase {
 /**
  * testMissingAction method
  *
- * @expectedException \Cake\Controller\Error\MissingActionException
+ * @expectedException \Cake\Controller\Exception\MissingActionException
  * @expectedExceptionMessage Action TestController::missing() could not be found.
  * @return void
  */
@@ -738,7 +738,7 @@ class ControllerTest extends TestCase {
 /**
  * test invoking private methods.
  *
- * @expectedException \Cake\Controller\Error\PrivateActionException
+ * @expectedException \Cake\Controller\Exception\PrivateActionException
  * @expectedExceptionMessage Private Action TestController::private_m() is not directly accessible.
  * @return void
  */
@@ -754,7 +754,7 @@ class ControllerTest extends TestCase {
 /**
  * test invoking protected methods.
  *
- * @expectedException \Cake\Controller\Error\PrivateActionException
+ * @expectedException \Cake\Controller\Exception\PrivateActionException
  * @expectedExceptionMessage Private Action TestController::protected_m() is not directly accessible.
  * @return void
  */
@@ -770,7 +770,7 @@ class ControllerTest extends TestCase {
 /**
  * test invoking hidden methods.
  *
- * @expectedException \Cake\Controller\Error\PrivateActionException
+ * @expectedException \Cake\Controller\Exception\PrivateActionException
  * @expectedExceptionMessage Private Action TestController::_hidden() is not directly accessible.
  * @return void
  */
@@ -786,7 +786,7 @@ class ControllerTest extends TestCase {
 /**
  * test invoking controller methods.
  *
- * @expectedException \Cake\Controller\Error\PrivateActionException
+ * @expectedException \Cake\Controller\Exception\PrivateActionException
  * @expectedExceptionMessage Private Action TestController::redirect() is not directly accessible.
  * @return void
  */

+ 4 - 4
tests/TestCase/Error/ExceptionRendererTest.php

@@ -16,10 +16,9 @@ namespace Cake\Test\TestCase\Error;
 
 use Cake\Controller\Component;
 use Cake\Controller\Controller;
-use Cake\Controller\Error\MissingActionException;
-use Cake\Controller\Error\MissingComponentException;
-use Cake\Controller\Error\MissingControllerException;
-use Cake\Controller\Error\PrivateActionException;
+use Cake\Controller\Exception\MissingActionException;
+use Cake\Controller\Exception\MissingComponentException;
+use Cake\Controller\Exception\PrivateActionException;
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Exception\MissingPluginException;
@@ -35,6 +34,7 @@ use Cake\Network\Exception\NotFoundException;
 use Cake\Network\Exception\SocketException;
 use Cake\Network\Request;
 use Cake\ORM\Error\MissingBehaviorException;
+use Cake\Routing\Error\MissingControllerException;
 use Cake\Routing\Router;
 use Cake\TestSuite\TestCase;
 use Cake\View\Error\MissingHelperException;

+ 3 - 5
tests/TestCase/Routing/DispatcherTest.php

@@ -14,8 +14,6 @@
 namespace Cake\Test\TestCase\Routing;
 
 use Cake\Controller\Controller;
-use Cake\Controller\Error\MissingActionException;
-use Cake\Controller\Error\MissingControllerException;
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
@@ -234,7 +232,7 @@ class DispatcherTest extends TestCase {
 /**
  * testMissingController method
  *
- * @expectedException \Cake\Controller\Error\MissingControllerException
+ * @expectedException \Cake\Routing\Error\MissingControllerException
  * @expectedExceptionMessage Controller class SomeController could not be found.
  * @return void
  */
@@ -253,7 +251,7 @@ class DispatcherTest extends TestCase {
 /**
  * testMissingControllerInterface method
  *
- * @expectedException \Cake\Controller\Error\MissingControllerException
+ * @expectedException \Cake\Routing\Error\MissingControllerException
  * @expectedExceptionMessage Controller class DispatcherTestInterface could not be found.
  * @return void
  */
@@ -273,7 +271,7 @@ class DispatcherTest extends TestCase {
 /**
  * testMissingControllerInterface method
  *
- * @expectedException \Cake\Controller\Error\MissingControllerException
+ * @expectedException \Cake\Routing\Error\MissingControllerException
  * @expectedExceptionMessage Controller class Abstract could not be found.
  * @return void
  */

+ 1 - 1
tests/TestCase/TestSuite/ControllerTestCaseTest.php

@@ -261,7 +261,7 @@ class ControllerTestCaseTest extends TestCase {
 /**
  * Tests not using loaded routes during tests
  *
- * @expectedException \Cake\Controller\Error\MissingActionException
+ * @expectedException \Cake\Controller\Exception\MissingActionException
  * @return void
  */
 	public function testSkipRoutes() {