Skip to content
Permalink
Browse files

Routing\Error -> Routing\Exception

  • Loading branch information...
lorenzo committed Aug 30, 2014
1 parent 6f0bad0 commit 5840bf2a7ba1e5ddb986c002ae3e5e9ddd98f42a
@@ -20,13 +20,13 @@
use Cake\Event\EventManagerTrait;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Routing\Error\MissingControllerException;
use Cake\Routing\Exception\MissingControllerException;
use LogicException;
/**
* Dispatcher converts Requests into controller actions. It uses the dispatched Request
* to locate and load the correct controller. If found, the requested action is called on
* the controller.
* the controller
*
*/
class Dispatcher {
@@ -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\Routing\Error\MissingControllerException When the controller is missing.
* @throws \Cake\Routing\Exception\MissingControllerException When the controller is missing.
*/
public function dispatch(Request $request, Response $response) {
$beforeEvent = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response'));
@@ -16,7 +16,7 @@
use Cake\Core\App;
use Cake\Routing\Dispatcher;
use Cake\Routing\Error\MissingDispatcherFilterException;
use Cake\Routing\Exception\MissingDispatcherFilterException;
/**
* A factory for creating dispatchers with all the desired middleware
@@ -58,7 +58,7 @@ public static function add($filter, array $options = []) {
* @param string $name The name of the filter to build.
* @param array $options Constructor arguments/options for the filter.
* @return \Cake\Routing\DispatcherFilter
* @throws \Cake\Routing\Error\MissingDispatcherFilterException When filters cannot be found.
* @throws \Cake\Routing\Exception\MissingDispatcherFilterException When filters cannot be found.
*/
protected static function _createFilter($name, $options) {
$className = App::className($name, 'Routing/Filter', 'Filter');
@@ -14,10 +14,10 @@
*/
namespace Cake\Routing;
use Cake\Core\Exception\Exception;
use Cake\Core\InstanceConfigTrait;
use Cake\Event\Event;
use Cake\Event\EventListener;
use InvalidArgumentException;
/**
* This abstract class represents a filter to be applied to a dispatcher cycle. It acts as as
@@ -94,15 +94,15 @@ class DispatcherFilter implements EventListener {
* Constructor.
*
* @param array $config Settings for the filter.
* @throws \Cake\Core\Exception\Exception When 'when' conditions are not callable.
* @throws \InvalidArgumentException When 'when' conditions are not callable.
*/
public function __construct($config = []) {
if (!isset($config['priority'])) {
$config['priority'] = $this->_priority;
}
$this->config($config);
if (isset($config['when']) && !is_callable($config['when'])) {
throw new Exception('"when" conditions must be a callable.');
throw new InvalidArgumentException('"when" conditions must be a callable.');
}
}
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Routing\Error;
namespace Cake\Routing\Exception;
use Cake\Core\Exception\Exception;
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Routing\Error;
namespace Cake\Routing\Exception;
use Cake\Core\Exception\Exception;
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Routing\Error;
namespace Cake\Routing\Exception;
use Cake\Core\Exception\Exception;
@@ -14,11 +14,12 @@
*/
namespace Cake\Routing;
use BadMethodCallException;
use Cake\Core\App;
use Cake\Core\Exception\Exception;
use Cake\Routing\Router;
use Cake\Routing\Route\Route;
use Cake\Routing\Router;
use Cake\Utility\Inflector;
use InvalidArgumentException;
/**
* Provides features for building routes inside scopes.
@@ -310,7 +311,8 @@ public function resources($name, $options = [], $callback = null) {
* shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a
* custom routing class.
* @return void
* @throws \Cake\Core\Exception\Exception
* @throws \InvalidArgumentException
* @throws \BadMethodCallException
*/
public function connect($route, array $defaults = [], $options = []) {
if (empty($options['action'])) {
@@ -332,7 +334,8 @@ public function connect($route, array $defaults = [], $options = []) {
* @param array $defaults Default parameters.
* @param array $options Additional options parameters.
* @return \Cake\Routing\Route\Route
* @throws \Cake\Core\Exception\Exception when route class or route object is invalid.
* @throws \InvalidArgumentException when route class or route object is invalid.
* @throws \BadMethodCallException when the route to make conflicts with the current scope
*/
protected function _makeRoute($route, $defaults, $options) {
if (is_string($route)) {
@@ -341,7 +344,7 @@ protected function _makeRoute($route, $defaults, $options) {
$routeClass = App::className($options['routeClass'], 'Routing/Route');
}
if ($routeClass === false) {
throw new Exception(sprintf('Cannot find route class %s', $options['routeClass']));
throw new InvalidArgumentException(sprintf('Cannot find route class %s', $options['routeClass']));
}
unset($options['routeClass']);
@@ -352,7 +355,7 @@ protected function _makeRoute($route, $defaults, $options) {
if (isset($defaults[$param]) && $defaults[$param] !== $val) {
$msg = 'You cannot define routes that conflict with the scope. ' .
'Scope had %s = %s, while route had %s = %s';
throw new Exception(sprintf(
throw new BadMethodCallException(sprintf(
$msg,
$param,
$val,
@@ -370,7 +373,9 @@ protected function _makeRoute($route, $defaults, $options) {
if ($route instanceof Route) {
return $route;
}
throw new Exception('Route class not found, or route class is not a subclass of Cake\Routing\Route\Route');
throw new InvalidArgumentException(
'Route class not found, or route class is not a subclass of Cake\Routing\Route\Route'
);
}
/**
@@ -16,7 +16,7 @@
use Cake\Core\App;
use Cake\Error;
use Cake\Routing\Error\MissingRouteException;
use Cake\Routing\Exception\MissingRouteException;
use Cake\Routing\Router;
use Cake\Routing\Route\Route;
use Cake\Utility\Inflector;
@@ -108,7 +108,7 @@ public function add(Route $route, $options = []) {
*
* @param string $url URL to parse.
* @return array An array of request parameters parsed from the URL.
* @throws \Cake\Routing\Error\MissingRouteException When a URL has no matching route.
* @throws \Cake\Routing\Exception\MissingRouteException When a URL has no matching route.
*/
public function parse($url) {
foreach (array_keys($this->_paths) as $path) {
@@ -224,7 +224,7 @@ protected function _getNames($url) {
* @param array $context The request context to use. Contains _base, _port,
* _host, and _scheme keys.
* @return string|false Either a string on match, or false on failure.
* @throws \Cake\Routing\Error\MissingRouteException when a route cannot be matched.
* @throws \Cake\Routing\Exception\MissingRouteException when a route cannot be matched.
*/
public function match($url, $context) {
// Named routes support optimization.
@@ -283,7 +283,7 @@ public static function mapResources($controller, $options = []) {
*
* @param string $url URL to be parsed
* @return array Parsed elements from URL
* @throws \Cake\Routing\Error\MissingRouteException When a route cannot be handled
* @throws \Cake\Routing\Exception\MissingRouteException When a route cannot be handled
*/
public static function parse($url) {
if (!static::$initialized) {
@@ -34,7 +34,7 @@
use Cake\Network\Exception\SocketException;
use Cake\Network\Request;
use Cake\ORM\Error\MissingBehaviorException;
use Cake\Routing\Error\MissingControllerException;
use Cake\Routing\Exception\MissingControllerException;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use Cake\View\Exception\MissingHelperException;
@@ -56,7 +56,7 @@ public function testAddFilterString() {
/**
* Test add filter missing
*
* @expectedException Cake\Routing\Error\MissingDispatcherFilterException
* @expectedException Cake\Routing\Exception\MissingDispatcherFilterException
* @return void
*/
public function testAddFilterMissing() {
@@ -63,7 +63,7 @@ public function testImplementedEvents() {
/**
* Test constructor error invalid when
*
* @expectedException Cake\Core\Exception\Exception
* @expectedException InvalidArgumentException
* @expectedExceptionMessage "when" conditions must be a callable.
* @return void
*/
@@ -17,7 +17,6 @@
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Error;
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\Network\Response;
@@ -232,7 +231,7 @@ public function tearDown() {
/**
* testMissingController method
*
* @expectedException \Cake\Routing\Error\MissingControllerException
* @expectedException \Cake\Routing\Exception\MissingControllerException
* @expectedExceptionMessage Controller class SomeController could not be found.
* @return void
*/
@@ -251,7 +250,7 @@ public function testMissingController() {
/**
* testMissingControllerInterface method
*
* @expectedException \Cake\Routing\Error\MissingControllerException
* @expectedException \Cake\Routing\Exception\MissingControllerException
* @expectedExceptionMessage Controller class DispatcherTestInterface could not be found.
* @return void
*/
@@ -271,7 +270,7 @@ public function testMissingControllerInterface() {
/**
* testMissingControllerInterface method
*
* @expectedException \Cake\Routing\Error\MissingControllerException
* @expectedException \Cake\Routing\Exception\MissingControllerException
* @expectedExceptionMessage Controller class Abstract could not be found.
* @return void
*/
@@ -162,7 +162,7 @@ public function testExtensionsString() {
/**
* Test error on invalid route class
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Route class not found, or route class is not a subclass of
* @return void
*/
@@ -174,7 +174,7 @@ public function testConnectErrorInvalidRouteClass() {
/**
* Test conflicting parameters raises an exception.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException \BadMethodCallException
* @expectedExceptionMessage You cannot define routes that conflict with the scope.
* @return void
*/
@@ -35,7 +35,7 @@ public function setUp() {
/**
* Test parse() throws an error on unknown routes.
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
* @expectedExceptionMessage A route matching "/" could not be found
*/
public function testParseMissingRoute() {
@@ -126,7 +126,7 @@ public function testParseFallback() {
/**
* Test match() throws an error on unknown routes.
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
* @expectedExceptionMessage A route matching "array (
*/
public function testMatchError() {
@@ -191,7 +191,7 @@ public function testMatchNamed() {
/**
* Test matching routes with names and failing
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
* @return void
*/
public function testMatchNamedError() {
@@ -1081,7 +1081,7 @@ public function testUrlGenerationNamedRoute() {
/**
* Test that using invalid names causes exceptions.
*
* @expectedException \Cake\Routing\Error\MissingRouteException
* @expectedException \Cake\Routing\Exception\MissingRouteException
* @return void
*/
public function testNamedRouteException() {
@@ -1493,7 +1493,7 @@ public function testRouteSymmetry() {
/**
* Test exceptions when parsing fails.
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
*/
public function testParseError() {
Router::connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
@@ -1993,7 +1993,7 @@ public function testParsingWithTrailingPeriodAndParseExtensions() {
/**
* test that patterns work for :action
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
* @return void
*/
public function testParsingWithPatternOnAction() {
@@ -2018,7 +2018,7 @@ public function testParsingWithPatternOnAction() {
/**
* Test url() works with patterns on :action
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
* @return void
*/
public function testUrlPatternOnAction() {
@@ -2194,7 +2194,7 @@ public function testRegexRouteMatching() {
/**
* testRegexRouteMatching error
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
* @return void
*/
public function testRegexRouteMatchingError() {
@@ -2205,7 +2205,7 @@ public function testRegexRouteMatchingError() {
/**
* testRegexRouteMatching method
*
* @expectedException Cake\Routing\Error\MissingRouteException
* @expectedException Cake\Routing\Exception\MissingRouteException
* @return void
*/
public function testRegexRouteMatchUrl() {

0 comments on commit 5840bf2

Please sign in to comment.
You can’t perform that action at this time.