From 22f90f767cd1d34eb73d338c9187bc2ebebd6ac5 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 30 Aug 2014 21:17:22 +0200 Subject: [PATCH] Controller\Error -> Controller\Exception Also moved MissingControllerException to Router, as it has a better home there --- src/Controller/ComponentRegistry.php | 7 ++++--- src/Controller/Controller.php | 11 ++++++----- .../{Error => Exception}/MissingActionException.php | 2 +- .../MissingComponentException.php | 2 +- .../{Error => Exception}/PrivateActionException.php | 2 +- src/Routing/Dispatcher.php | 10 +++++----- .../Error/MissingControllerException.php | 2 +- tests/TestCase/Console/ConsoleErrorHandlerTest.php | 2 +- tests/TestCase/Controller/ComponentRegistryTest.php | 2 +- tests/TestCase/Controller/ControllerTest.php | 10 +++++----- tests/TestCase/Error/ExceptionRendererTest.php | 8 ++++---- tests/TestCase/Routing/DispatcherTest.php | 8 +++----- tests/TestCase/TestSuite/ControllerTestCaseTest.php | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) rename src/Controller/{Error => Exception}/MissingActionException.php (96%) rename src/Controller/{Error => Exception}/MissingComponentException.php (95%) rename src/Controller/{Error => Exception}/PrivateActionException.php (96%) rename src/{Controller => Routing}/Error/MissingControllerException.php (96%) diff --git a/src/Controller/ComponentRegistry.php b/src/Controller/ComponentRegistry.php index 7e468ae5f57..34bec041547 100644 --- a/src/Controller/ComponentRegistry.php +++ b/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 @@ protected function _resolveClassName($class) { * @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 ]); diff --git a/src/Controller/Controller.php b/src/Controller/Controller.php index 87fbd8bd5d3..6550582d620 100644 --- a/src/Controller/Controller.php +++ b/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 @@ public function setRequest(Request $request) { * * @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 @@ public function invokeAction() { } $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 @@ public function invokeAction() { 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'] : '', diff --git a/src/Controller/Error/MissingActionException.php b/src/Controller/Exception/MissingActionException.php similarity index 96% rename from src/Controller/Error/MissingActionException.php rename to src/Controller/Exception/MissingActionException.php index 48139ac20ea..d9fb56a818f 100644 --- a/src/Controller/Error/MissingActionException.php +++ b/src/Controller/Exception/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; diff --git a/src/Controller/Error/MissingComponentException.php b/src/Controller/Exception/MissingComponentException.php similarity index 95% rename from src/Controller/Error/MissingComponentException.php rename to src/Controller/Exception/MissingComponentException.php index 9018e0333ef..34e154e7353 100644 --- a/src/Controller/Error/MissingComponentException.php +++ b/src/Controller/Exception/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; diff --git a/src/Controller/Error/PrivateActionException.php b/src/Controller/Exception/PrivateActionException.php similarity index 96% rename from src/Controller/Error/PrivateActionException.php rename to src/Controller/Exception/PrivateActionException.php index 9f6fed10904..209fb6af0f0 100644 --- a/src/Controller/Error/PrivateActionException.php +++ b/src/Controller/Exception/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; diff --git a/src/Routing/Dispatcher.php b/src/Routing/Dispatcher.php index 3866870daf4..accb6a70449 100644 --- a/src/Routing/Dispatcher.php +++ b/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 @@ public function dispatch(Request $request, Response $response) { * * @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 @@ protected function _invoke(Controller $controller) { $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) { diff --git a/src/Controller/Error/MissingControllerException.php b/src/Routing/Error/MissingControllerException.php similarity index 96% rename from src/Controller/Error/MissingControllerException.php rename to src/Routing/Error/MissingControllerException.php index 71a8980c70f..e1c02f997b6 100644 --- a/src/Controller/Error/MissingControllerException.php +++ b/src/Routing/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; diff --git a/tests/TestCase/Console/ConsoleErrorHandlerTest.php b/tests/TestCase/Console/ConsoleErrorHandlerTest.php index cda8fdb19be..210a2b61fc0 100644 --- a/tests/TestCase/Console/ConsoleErrorHandlerTest.php +++ b/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; diff --git a/tests/TestCase/Controller/ComponentRegistryTest.php b/tests/TestCase/Controller/ComponentRegistryTest.php index c1fd495e782..12c9aa3441f 100644 --- a/tests/TestCase/Controller/ComponentRegistryTest.php +++ b/tests/TestCase/Controller/ComponentRegistryTest.php @@ -116,7 +116,7 @@ public function testLoadWithEnableFalse() { /** * test missingcomponent exception * - * @expectedException \Cake\Controller\Error\MissingComponentException + * @expectedException \Cake\Controller\Exception\MissingComponentException * @return void */ public function testLoadMissingComponent() { diff --git a/tests/TestCase/Controller/ControllerTest.php b/tests/TestCase/Controller/ControllerTest.php index 0f6a490a94b..610c2ca381a 100644 --- a/tests/TestCase/Controller/ControllerTest.php +++ b/tests/TestCase/Controller/ControllerTest.php @@ -722,7 +722,7 @@ public function testPaginateUsesModelClass() { /** * 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 @@ public function testInvokeActionMissingAction() { /** * 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 @@ public function testInvokeActionPrivate() { /** * 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 @@ public function testInvokeActionProtected() { /** * 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 @@ public function testInvokeActionHidden() { /** * 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 */ diff --git a/tests/TestCase/Error/ExceptionRendererTest.php b/tests/TestCase/Error/ExceptionRendererTest.php index ab568c8c302..3bc69dbcd9a 100644 --- a/tests/TestCase/Error/ExceptionRendererTest.php +++ b/tests/TestCase/Error/ExceptionRendererTest.php @@ -16,10 +16,9 @@ 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\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; diff --git a/tests/TestCase/Routing/DispatcherTest.php b/tests/TestCase/Routing/DispatcherTest.php index 32f47babe97..f72bb7d92b1 100644 --- a/tests/TestCase/Routing/DispatcherTest.php +++ b/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 @@ public function tearDown() { /** * 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 @@ public function testMissingController() { /** * 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 @@ public function testMissingControllerInterface() { /** * testMissingControllerInterface method * - * @expectedException \Cake\Controller\Error\MissingControllerException + * @expectedException \Cake\Routing\Error\MissingControllerException * @expectedExceptionMessage Controller class Abstract could not be found. * @return void */ diff --git a/tests/TestCase/TestSuite/ControllerTestCaseTest.php b/tests/TestCase/TestSuite/ControllerTestCaseTest.php index 810a04c9b43..d7be592d64e 100644 --- a/tests/TestCase/TestSuite/ControllerTestCaseTest.php +++ b/tests/TestCase/TestSuite/ControllerTestCaseTest.php @@ -261,7 +261,7 @@ public function testTestActionWithPlugin() { /** * Tests not using loaded routes during tests * - * @expectedException \Cake\Controller\Error\MissingActionException + * @expectedException \Cake\Controller\Exception\MissingActionException * @return void */ public function testSkipRoutes() {