Skip to content

Commit

Permalink
Controller\Error -> Controller\Exception
Browse files Browse the repository at this point in the history
Also moved MissingControllerException to Router, as it has a better home there
  • Loading branch information
lorenzo committed Aug 30, 2014
1 parent cb83b3f commit 22f90f7
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
7 changes: 4 additions & 3 deletions src/Controller/ComponentRegistry.php
Expand Up @@ -14,9 +14,10 @@
*/ */
namespace Cake\Controller; namespace Cake\Controller;


use Cake\Controller\Exception\MissingComponentException;
use Cake\Core\App; use Cake\Core\App;
use Cake\Event\EventManagerTrait;
use Cake\Core\ObjectRegistry; use Cake\Core\ObjectRegistry;
use Cake\Event\EventManagerTrait;


/** /**
* ComponentRegistry is a registry for loaded components * ComponentRegistry is a registry for loaded components
Expand Down Expand Up @@ -75,10 +76,10 @@ protected function _resolveClassName($class) {
* @param string $class The classname that is missing. * @param string $class The classname that is missing.
* @param string $plugin The plugin the component is missing in. * @param string $plugin The plugin the component is missing in.
* @return void * @return void
* @throws \Cake\Controller\Error\MissingComponentException * @throws \Cake\Controller\Exception\MissingComponentException
*/ */
protected function _throwMissingClassError($class, $plugin) { protected function _throwMissingClassError($class, $plugin) {
throw new Error\MissingComponentException([ throw new MissingComponentException([
'class' => $class . 'Component', 'class' => $class . 'Component',
'plugin' => $plugin 'plugin' => $plugin
]); ]);
Expand Down
11 changes: 6 additions & 5 deletions src/Controller/Controller.php
Expand Up @@ -14,7 +14,8 @@
*/ */
namespace Cake\Controller; 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\Event;
use Cake\Event\EventListener; use Cake\Event\EventListener;
use Cake\Event\EventManagerTrait; use Cake\Event\EventManagerTrait;
Expand Down Expand Up @@ -352,8 +353,8 @@ public function setRequest(Request $request) {
* *
* @return mixed The resulting response. * @return mixed The resulting response.
* @throws \LogicException When request is not set. * @throws \LogicException When request is not set.
* @throws \Cake\Controller\Error\PrivateActionException When actions are not public or prefixed by _ * @throws \Cake\Controller\Exception\PrivateActionException When actions are not public or prefixed by _
* @throws \Cake\Controller\Error\MissingActionException When actions are not defined. * @throws \Cake\Controller\Exception\MissingActionException When actions are not defined.
*/ */
public function invokeAction() { public function invokeAction() {
try { try {
Expand All @@ -363,7 +364,7 @@ public function invokeAction() {
} }
$method = new \ReflectionMethod($this, $request->params['action']); $method = new \ReflectionMethod($this, $request->params['action']);
if ($this->_isPrivateAction($method, $request)) { if ($this->_isPrivateAction($method, $request)) {
throw new Error\PrivateActionException(array( throw new PrivateActionException(array(
'controller' => $this->name . "Controller", 'controller' => $this->name . "Controller",
'action' => $request->params['action'], 'action' => $request->params['action'],
'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '', 'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '',
Expand All @@ -373,7 +374,7 @@ public function invokeAction() {
return $method->invokeArgs($this, $request->params['pass']); return $method->invokeArgs($this, $request->params['pass']);


} catch (\ReflectionException $e) { } catch (\ReflectionException $e) {
throw new Error\MissingActionException(array( throw new MissingActionException(array(
'controller' => $this->name . "Controller", 'controller' => $this->name . "Controller",
'action' => $request->params['action'], 'action' => $request->params['action'],
'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '', 'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '',
Expand Down
Expand Up @@ -11,7 +11,7 @@
* @since 3.0.0 * @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
namespace Cake\Controller\Error; namespace Cake\Controller\Exception;


use Cake\Core\Exception\Exception; use Cake\Core\Exception\Exception;


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


use Cake\Core\Exception\Exception; use Cake\Core\Exception\Exception;


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


use Cake\Core\Exception\Exception; use Cake\Core\Exception\Exception;


Expand Down
10 changes: 5 additions & 5 deletions src/Routing/Dispatcher.php
Expand Up @@ -15,13 +15,13 @@
namespace Cake\Routing; namespace Cake\Routing;


use Cake\Controller\Controller; use Cake\Controller\Controller;
use Cake\Controller\Error\MissingControllerException;
use Cake\Core\Exception\Exception;
use Cake\Event\Event; use Cake\Event\Event;
use Cake\Event\EventListener; use Cake\Event\EventListener;
use Cake\Event\EventManagerTrait; use Cake\Event\EventManagerTrait;
use Cake\Network\Request; use Cake\Network\Request;
use Cake\Network\Response; use Cake\Network\Response;
use Cake\Routing\Error\MissingControllerException;
use LogicException;


/** /**
* Dispatcher converts Requests into controller actions. It uses the dispatched Request * Dispatcher converts Requests into controller actions. It uses the dispatched Request
Expand Down Expand Up @@ -55,7 +55,7 @@ class Dispatcher {
* @param \Cake\Network\Request $request Request object to dispatch. * @param \Cake\Network\Request $request Request object to dispatch.
* @param \Cake\Network\Response $response Response object to put the results of the dispatch into. * @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 * @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) { public function dispatch(Request $request, Response $response) {
$beforeEvent = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response')); $beforeEvent = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response'));
Expand Down Expand Up @@ -102,7 +102,7 @@ public function dispatch(Request $request, Response $response) {
* *
* @param Controller $controller Controller to invoke * @param Controller $controller Controller to invoke
* @return \Cake\Network\Response The resulting response object * @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 * instance of Response
*/ */
protected function _invoke(Controller $controller) { protected function _invoke(Controller $controller) {
Expand All @@ -114,7 +114,7 @@ protected function _invoke(Controller $controller) {


$response = $controller->invokeAction(); $response = $controller->invokeAction();
if ($response !== null && !($response instanceof Response)) { 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) { if (!$response && $controller->autoRender) {
Expand Down
Expand Up @@ -11,7 +11,7 @@
* @since 3.0.0 * @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
namespace Cake\Controller\Error; namespace Cake\Routing\Error;


use Cake\Core\Exception\Exception; use Cake\Core\Exception\Exception;


Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Console/ConsoleErrorHandlerTest.php
Expand Up @@ -15,7 +15,7 @@
namespace Cake\Test\TestCase\Console; namespace Cake\Test\TestCase\Console;


use Cake\Console\ConsoleErrorHandler; use Cake\Console\ConsoleErrorHandler;
use Cake\Controller\Error\MissingActionException; use Cake\Controller\Exception\MissingActionException;
use Cake\Core\Exception\Exception; use Cake\Core\Exception\Exception;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\Network\Exception\InternalErrorException; use Cake\Network\Exception\InternalErrorException;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Controller/ComponentRegistryTest.php
Expand Up @@ -116,7 +116,7 @@ public function testLoadWithEnableFalse() {
/** /**
* test missingcomponent exception * test missingcomponent exception
* *
* @expectedException \Cake\Controller\Error\MissingComponentException * @expectedException \Cake\Controller\Exception\MissingComponentException
* @return void * @return void
*/ */
public function testLoadMissingComponent() { public function testLoadMissingComponent() {
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -722,7 +722,7 @@ public function testPaginateUsesModelClass() {
/** /**
* testMissingAction method * testMissingAction method
* *
* @expectedException \Cake\Controller\Error\MissingActionException * @expectedException \Cake\Controller\Exception\MissingActionException
* @expectedExceptionMessage Action TestController::missing() could not be found. * @expectedExceptionMessage Action TestController::missing() could not be found.
* @return void * @return void
*/ */
Expand All @@ -738,7 +738,7 @@ public function testInvokeActionMissingAction() {
/** /**
* test invoking private methods. * test invoking private methods.
* *
* @expectedException \Cake\Controller\Error\PrivateActionException * @expectedException \Cake\Controller\Exception\PrivateActionException
* @expectedExceptionMessage Private Action TestController::private_m() is not directly accessible. * @expectedExceptionMessage Private Action TestController::private_m() is not directly accessible.
* @return void * @return void
*/ */
Expand All @@ -754,7 +754,7 @@ public function testInvokeActionPrivate() {
/** /**
* test invoking protected methods. * test invoking protected methods.
* *
* @expectedException \Cake\Controller\Error\PrivateActionException * @expectedException \Cake\Controller\Exception\PrivateActionException
* @expectedExceptionMessage Private Action TestController::protected_m() is not directly accessible. * @expectedExceptionMessage Private Action TestController::protected_m() is not directly accessible.
* @return void * @return void
*/ */
Expand All @@ -770,7 +770,7 @@ public function testInvokeActionProtected() {
/** /**
* test invoking hidden methods. * test invoking hidden methods.
* *
* @expectedException \Cake\Controller\Error\PrivateActionException * @expectedException \Cake\Controller\Exception\PrivateActionException
* @expectedExceptionMessage Private Action TestController::_hidden() is not directly accessible. * @expectedExceptionMessage Private Action TestController::_hidden() is not directly accessible.
* @return void * @return void
*/ */
Expand All @@ -786,7 +786,7 @@ public function testInvokeActionHidden() {
/** /**
* test invoking controller methods. * test invoking controller methods.
* *
* @expectedException \Cake\Controller\Error\PrivateActionException * @expectedException \Cake\Controller\Exception\PrivateActionException
* @expectedExceptionMessage Private Action TestController::redirect() is not directly accessible. * @expectedExceptionMessage Private Action TestController::redirect() is not directly accessible.
* @return void * @return void
*/ */
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Error/ExceptionRendererTest.php
Expand Up @@ -16,10 +16,9 @@


use Cake\Controller\Component; use Cake\Controller\Component;
use Cake\Controller\Controller; use Cake\Controller\Controller;
use Cake\Controller\Error\MissingActionException; use Cake\Controller\Exception\MissingActionException;
use Cake\Controller\Error\MissingComponentException; use Cake\Controller\Exception\MissingComponentException;
use Cake\Controller\Error\MissingControllerException; use Cake\Controller\Exception\PrivateActionException;
use Cake\Controller\Error\PrivateActionException;
use Cake\Core\App; use Cake\Core\App;
use Cake\Core\Configure; use Cake\Core\Configure;
use Cake\Core\Exception\MissingPluginException; use Cake\Core\Exception\MissingPluginException;
Expand All @@ -35,6 +34,7 @@
use Cake\Network\Exception\SocketException; use Cake\Network\Exception\SocketException;
use Cake\Network\Request; use Cake\Network\Request;
use Cake\ORM\Error\MissingBehaviorException; use Cake\ORM\Error\MissingBehaviorException;
use Cake\Routing\Error\MissingControllerException;
use Cake\Routing\Router; use Cake\Routing\Router;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use Cake\View\Error\MissingHelperException; use Cake\View\Error\MissingHelperException;
Expand Down
8 changes: 3 additions & 5 deletions tests/TestCase/Routing/DispatcherTest.php
Expand Up @@ -14,8 +14,6 @@
namespace Cake\Test\TestCase\Routing; namespace Cake\Test\TestCase\Routing;


use Cake\Controller\Controller; use Cake\Controller\Controller;
use Cake\Controller\Error\MissingActionException;
use Cake\Controller\Error\MissingControllerException;
use Cake\Core\App; use Cake\Core\App;
use Cake\Core\Configure; use Cake\Core\Configure;
use Cake\Core\Plugin; use Cake\Core\Plugin;
Expand Down Expand Up @@ -234,7 +232,7 @@ public function tearDown() {
/** /**
* testMissingController method * testMissingController method
* *
* @expectedException \Cake\Controller\Error\MissingControllerException * @expectedException \Cake\Routing\Error\MissingControllerException
* @expectedExceptionMessage Controller class SomeController could not be found. * @expectedExceptionMessage Controller class SomeController could not be found.
* @return void * @return void
*/ */
Expand All @@ -253,7 +251,7 @@ public function testMissingController() {
/** /**
* testMissingControllerInterface method * testMissingControllerInterface method
* *
* @expectedException \Cake\Controller\Error\MissingControllerException * @expectedException \Cake\Routing\Error\MissingControllerException
* @expectedExceptionMessage Controller class DispatcherTestInterface could not be found. * @expectedExceptionMessage Controller class DispatcherTestInterface could not be found.
* @return void * @return void
*/ */
Expand All @@ -273,7 +271,7 @@ public function testMissingControllerInterface() {
/** /**
* testMissingControllerInterface method * testMissingControllerInterface method
* *
* @expectedException \Cake\Controller\Error\MissingControllerException * @expectedException \Cake\Routing\Error\MissingControllerException
* @expectedExceptionMessage Controller class Abstract could not be found. * @expectedExceptionMessage Controller class Abstract could not be found.
* @return void * @return void
*/ */
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/TestSuite/ControllerTestCaseTest.php
Expand Up @@ -261,7 +261,7 @@ public function testTestActionWithPlugin() {
/** /**
* Tests not using loaded routes during tests * Tests not using loaded routes during tests
* *
* @expectedException \Cake\Controller\Error\MissingActionException * @expectedException \Cake\Controller\Exception\MissingActionException
* @return void * @return void
*/ */
public function testSkipRoutes() { public function testSkipRoutes() {
Expand Down

0 comments on commit 22f90f7

Please sign in to comment.