Browse Source

Moved Http exceptions to the Network namespaces

Also sarted to remove the hard dependency on Core\Exception\Exception
where it offers no added value
Jose Lorenzo Rodriguez 11 years ago
parent
commit
d6dcee431a

+ 3 - 3
src/Auth/BasicAuthenticate.php

@@ -14,7 +14,7 @@
  */
 namespace Cake\Auth;
 
-use Cake\Error;
+use Cake\Network\Exception\UnauthorizedException;
 use Cake\Network\Request;
 use Cake\Network\Response;
 
@@ -85,10 +85,10 @@ class BasicAuthenticate extends BaseAuthenticate {
  * @param Request $request A request object.
  * @param Response $response A response object.
  * @return void
- * @throws \Cake\Error\UnauthorizedException
+ * @throws \Cake\Network\Exception\UnauthorizedException
  */
 	public function unauthenticated(Request $request, Response $response) {
-		$Exception = new Error\UnauthorizedException();
+		$Exception = new UnauthorizedException();
 		$Exception->responseHeader(array($this->loginHeaders($request)));
 		throw $Exception;
 	}

+ 3 - 3
src/Controller/Component/AuthComponent.php

@@ -19,9 +19,9 @@ use Cake\Controller\ComponentRegistry;
 use Cake\Controller\Controller;
 use Cake\Core\App;
 use Cake\Core\Exception\Exception;
-use Cake\Error;
 use Cake\Error\Debugger;
 use Cake\Event\Event;
+use Cake\Network\Exception\ForbiddenException;
 use Cake\Network\Request;
 use Cake\Network\Response;
 use Cake\Routing\Router;
@@ -391,11 +391,11 @@ class AuthComponent extends Component {
  *
  * @param \Cake\Controller\Controller $controller A reference to the controller object
  * @return \Cake\Network\Response
- * @throws \Cake\Error\ForbiddenException
+ * @throws \Cake\Network\Exception\ForbiddenException
  */
 	protected function _unauthorized(Controller $controller) {
 		if ($this->_config['unauthorizedRedirect'] === false) {
-			throw new Error\ForbiddenException($this->_config['authError']);
+			throw new ForbiddenException($this->_config['authError']);
 		}
 
 		$this->flash($this->_config['authError']);

+ 2 - 2
src/Controller/Component/CsrfComponent.php

@@ -15,8 +15,8 @@
 namespace Cake\Controller\Component;
 
 use Cake\Controller\Component;
-use Cake\Error\ForbiddenException;
 use Cake\Event\Event;
+use Cake\Network\Exception\ForbiddenException;
 use Cake\Network\Request;
 use Cake\Network\Response;
 use Cake\Utility\Security;
@@ -131,7 +131,7 @@ class CsrfComponent extends Component {
  * Validate the request data against the cookie token.
  *
  * @param \Cake\Network\Request $request The request to validate against.
- * @throws \Cake\Error\ForbiddenException when the CSRF token is invalid or missing.
+ * @throws \Cake\Network\Exception\ForbiddenException when the CSRF token is invalid or missing.
  * @return void
  */
 	protected function _validateToken(Request $request) {

+ 3 - 3
src/Controller/Component/PaginatorComponent.php

@@ -15,7 +15,7 @@
 namespace Cake\Controller\Component;
 
 use Cake\Controller\Component;
-use Cake\Error;
+use Cake\Network\Exception\NotFoundException;
 use Cake\ORM\Query;
 use Cake\ORM\Table;
 
@@ -140,7 +140,7 @@ class PaginatorComponent extends Component {
  * @param \Cake\Datasource\RepositoryInterface|\Cake\ORM\Query $object The table or query to paginate.
  * @param array $settings The settings/configuration used for pagination.
  * @return array Query results
- * @throws \Cake\Error\NotFoundException
+ * @throws \Cake\Network\Exception\NotFoundException
  */
 	public function paginate($object, array $settings = []) {
 		if ($object instanceof Query) {
@@ -214,7 +214,7 @@ class PaginatorComponent extends Component {
 		);
 
 		if ($requestedPage > $page) {
-			throw new Error\NotFoundException();
+			throw new NotFoundException();
 		}
 
 		return $results;

+ 5 - 5
src/Controller/Component/SecurityComponent.php

@@ -17,8 +17,8 @@ namespace Cake\Controller\Component;
 use Cake\Controller\Component;
 use Cake\Controller\Controller;
 use Cake\Core\Configure;
-use Cake\Error;
 use Cake\Event\Event;
+use Cake\Network\Exception\BadRequestException;
 use Cake\Network\Request;
 use Cake\Utility\Hash;
 use Cake\Utility\Security;
@@ -175,11 +175,11 @@ class SecurityComponent extends Component {
  * @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
  * @see SecurityComponent::$blackHoleCallback
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#handling-blackhole-callbacks
- * @throws \Cake\Error\BadRequestException
+ * @throws \Cake\Network\Exception\BadRequestException
  */
 	public function blackHole(Controller $controller, $error = '') {
 		if (!$this->_config['blackHoleCallback']) {
-			throw new Error\BadRequestException('The request has been black-holed');
+			throw new BadRequestException('The request has been black-holed');
 		}
 		return $this->_callback($controller, $this->_config['blackHoleCallback'], array($error));
 	}
@@ -388,11 +388,11 @@ class SecurityComponent extends Component {
  * @param string $method Method to execute
  * @param array $params Parameters to send to method
  * @return mixed Controller callback method's response
- * @throws \Cake\Error\BadRequestException When a the blackholeCallback is not callable.
+ * @throws \Cake\Network\Exception\BadRequestException When a the blackholeCallback is not callable.
  */
 	protected function _callback(Controller $controller, $method, $params = array()) {
 		if (!is_callable(array($controller, $method))) {
-			throw new Error\BadRequestException('The request has been black-holed');
+			throw new BadRequestException('The request has been black-holed');
 		}
 		return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
 	}

+ 3 - 2
src/Controller/Controller.php

@@ -28,6 +28,7 @@ use Cake\Routing\Router;
 use Cake\Utility\Inflector;
 use Cake\Utility\MergeVariablesTrait;
 use Cake\View\ViewVarsTrait;
+use LogicException;
 
 /**
  * Application controller class for organization of business logic.
@@ -350,7 +351,7 @@ class Controller implements EventListener {
  * exists and isn't private.
  *
  * @return mixed The resulting response.
- * @throws \Cake\Core\Exception\Exception 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\Error\MissingActionException When actions are not defined.
  */
@@ -358,7 +359,7 @@ class Controller implements EventListener {
 		try {
 			$request = $this->request;
 			if (!isset($request)) {
-				throw new Exception('No Request object configured. Cannot invoke action');
+				throw new LogicException('No Request object configured. Cannot invoke action');
 			}
 			$method = new \ReflectionMethod($this, $request->params['action']);
 			if ($this->_isPrivateAction($method, $request)) {

+ 1 - 0
src/Error/BaseErrorHandler.php

@@ -18,6 +18,7 @@ use Cake\Core\Configure;
 use Cake\Error\Debugger;
 use Cake\Log\Log;
 use Cake\Routing\Router;
+use Cake\Network\Exception\InternalErrorException;
 
 /**
  * Base error handler that provides logic common to the CLI + web

+ 6 - 4
src/Error/Debugger.php

@@ -15,10 +15,11 @@
 namespace Cake\Error;
 
 use Cake\Core\Configure;
-use Cake\Core\Exception\Exception;
 use Cake\Log\Log;
 use Cake\Utility\Hash;
 use Cake\Utility\String;
+use Exception;
+use InvalidArgumentException;
 
 /**
  * Provide custom logging and error handling.
@@ -583,7 +584,7 @@ class Debugger {
 				return $out . "\n" .
 					substr(static::_array($var->__debugInfo(), $depth - 1, $indent), 1, -1) .
 					$end . '}';
-			} catch (\Exception $e) {
+			} catch (Exception $e) {
 				return $out . "\n(unable to export object)\n }";
 			}
 		}
@@ -625,15 +626,16 @@ class Debugger {
  * @param string $format The format you want errors to be output as.
  *   Leave null to get the current format.
  * @return mixed Returns null when setting. Returns the current format when getting.
- * @throws \Cake\Core\Exception\Exception when choosing a format that doesn't exist.
+ * @throws \InvalidArgumentException when choosing a format that doesn't exist.
  */
 	public static function outputAs($format = null) {
 		$self = Debugger::getInstance();
 		if ($format === null) {
 			return $self->_outputFormat;
 		}
+
 		if ($format !== false && !isset($self->_templates[$format])) {
-			throw new Exception('Invalid Debugger output format.');
+			throw new InvalidArgumentException('Invalid Debugger output format.');
 		}
 		$self->_outputFormat = $format;
 	}

+ 3 - 2
src/Error/ErrorHandler.php

@@ -18,6 +18,7 @@ namespace Cake\Error;
 
 use Cake\Core\App;
 use Cake\Error\Debugger;
+use Exception;
 
 /**
  * Error Handler provides basic error and exception handling for your application. It captures and
@@ -132,13 +133,13 @@ class ErrorHandler extends BaseErrorHandler {
 		$renderer = App::className($this->_options['exceptionRenderer'], 'Error');
 		try {
 			if (!$renderer) {
-				throw new \Exception("$renderer is an invalid class.");
+				throw new Exception("$renderer is an invalid class.");
 			}
 			$error = new $renderer($exception);
 			$response = $error->render();
 			$this->_clearOutput();
 			$this->_sendResponse($response);
-		} catch (\Exception $e) {
+		} catch (Exception $e) {
 			// Disable trace for internal errors.
 			$this->_options['trace'] = false;
 			$message = sprintf("[%s] %s\n%s", // Keeping same message format

+ 7 - 4
src/Error/ExceptionRenderer.php

@@ -17,14 +17,17 @@ namespace Cake\Error;
 use Cake\Controller\Controller;
 use Cake\Controller\ErrorController;
 use Cake\Core\Configure;
+use Cake\Core\Exception\Exception as CakeException;
 use Cake\Core\Exception\MissingPluginException;
 use Cake\Error;
 use Cake\Event\Event;
+use Cake\Network\Exception\HttpException;
 use Cake\Network\Request;
 use Cake\Network\Response;
 use Cake\Routing\Router;
 use Cake\Utility\Inflector;
 use Cake\View\Error\MissingViewException;
+use Exception;
 
 /**
  * Exception Renderer.
@@ -80,7 +83,7 @@ class ExceptionRenderer {
  *
  * @param \Exception $exception Exception
  */
-	public function __construct(\Exception $exception) {
+	public function __construct(Exception $exception) {
 		$this->error = $exception;
 		$this->controller = $this->_getController();
 	}
@@ -102,7 +105,7 @@ class ExceptionRenderer {
 		try {
 			$controller = new ErrorController($request, $response);
 			$controller->startupProcess();
-		} catch (\Exception $e) {
+		} catch (Exception $e) {
 			if (!empty($controller) && isset($controller->RequestHandler)) {
 				$event = new Event('Controller.startup', $controller);
 				$controller->RequestHandler->startup($event);
@@ -127,7 +130,7 @@ class ExceptionRenderer {
 		$template = $this->_template($exception, $method, $code);
 
 		$isDebug = Configure::read('debug');
-		if (($isDebug || $exception instanceof Error\HttpException) &&
+		if (($isDebug || $exception instanceof HttpException) &&
 			method_exists($this, $method)
 		) {
 			return $this->_customMethod($method, $exception);
@@ -148,7 +151,7 @@ class ExceptionRenderer {
 			'_serialize' => array('message', 'url', 'code')
 		));
 
-		if ($exception instanceof Error\Exception && $isDebug) {
+		if ($exception instanceof CakeException && $isDebug) {
 			$this->controller->set($this->error->getAttributes());
 		}
 		return $this->_outputMessage($template);

+ 1 - 1
src/Error/BadRequestException.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Error;
+namespace Cake\Network\Exception;
 
 /**
  * Represents an HTTP 400 error.

+ 1 - 1
src/Error/ForbiddenException.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Error;
+namespace Cake\Network\Exception;
 
 /**
  * Represents an HTTP 403 error.

+ 1 - 1
src/Error/HttpException.php

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

+ 2 - 1
src/Error/InternalErrorException.php

@@ -11,7 +11,8 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Error;
+
+namespace Cake\Network\Exception;
 
 /**
  * Represents an HTTP 500 error.

+ 1 - 1
src/Error/MethodNotAllowedException.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Error;
+namespace Cake\Network\Exception;
 
 /**
  * Represents an HTTP 405 error.

+ 1 - 1
src/Error/NotFoundException.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Error;
+namespace Cake\Network\Exception;
 
 /**
  * Represents an HTTP 404 error.

+ 1 - 1
src/Error/NotImplementedException.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Error;
+namespace Cake\Network\Exception;
 
 /**
  * Not Implemented Exception - used when an API method is not implemented

+ 3 - 3
src/Network/Error/SocketException.php

@@ -11,14 +11,14 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Error;
+namespace Cake\Network\Exception;
 
-use Cake\Core\Exception\Exception;
+use RuntimeException;
 
 /**
  * Exception class for Socket. This exception will be thrown from Socket, Email, HttpSocket
  * SmtpTransport, MailTransport and HttpResponse when it encounters an error.
  *
  */
-class SocketException extends Exception {
+class SocketException extends RuntimeException {
 }

+ 1 - 1
src/Error/UnauthorizedException.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Error;
+namespace Cake\Network\Exception;
 
 /**
  * Represents an HTTP 401 error.

+ 6 - 6
src/Network/Request.php

@@ -14,9 +14,9 @@
  */
 namespace Cake\Network;
 
+use BadMethodCallException;
 use Cake\Core\Configure;
-use Cake\Core\Exception\Exception;
-use Cake\Error;
+use Cake\Network\Exception\MethodNotAllowedException;
 use Cake\Network\Session;
 use Cake\Utility\Hash;
 
@@ -525,14 +525,14 @@ class Request implements \ArrayAccess {
  * @param string $name The method called
  * @param array $params Array of parameters for the method call
  * @return mixed
- * @throws \Cake\Core\Exception\Exception when an invalid method is called.
+ * @throws \BadMethodCallException when an invalid method is called.
  */
 	public function __call($name, $params) {
 		if (strpos($name, 'is') === 0) {
 			$type = strtolower(substr($name, 2));
 			return $this->is($type);
 		}
-		throw new Exception(sprintf('Method %s does not exist', $name));
+		throw new BadMethodCallException(sprintf('Method %s does not exist', $name));
 	}
 
 /**
@@ -1082,7 +1082,7 @@ class Request implements \ArrayAccess {
  *
  * @param string|array $methods Allowed HTTP request methods.
  * @return bool true
- * @throws \Cake\Error\MethodNotAllowedException
+ * @throws \Cake\Network\Exception\MethodNotAllowedException
  */
 	public function allowMethod($methods) {
 		$methods = (array)$methods;
@@ -1092,7 +1092,7 @@ class Request implements \ArrayAccess {
 			}
 		}
 		$allowed = strtoupper(implode(', ', $methods));
-		$e = new Error\MethodNotAllowedException();
+		$e = new MethodNotAllowedException();
 		$e->responseHeader('Allow', $allowed);
 		throw $e;
 	}

+ 8 - 7
src/Network/Response.php

@@ -15,9 +15,10 @@
 namespace Cake\Network;
 
 use Cake\Core\Configure;
-use Cake\Core\Exception\Exception;
 use Cake\Error;
 use Cake\Utility\File;
+use InvalidArgumentException;
+use RuntimeException;
 
 /**
  * Cake Response is responsible for managing the response text, status and headers of a HTTP response.
@@ -518,11 +519,11 @@ class Response {
  * @param string $name the header name
  * @param string $value the header value
  * @return void
- * @throws \Cake\Core\Exception\Exception When headers have already been sent
+ * @throws \RuntimeException When headers have already been sent
  */
 	protected function _sendHeader($name, $value = null) {
 		if (headers_sent($filename, $linenum)) {
-			throw new Exception(
+			throw new RuntimeException(
 				sprintf('Headers already sent in %d on line %s', $linenum, $filename)
 			);
 		}
@@ -625,14 +626,14 @@ class Response {
  *
  * @param int $code the HTTP status code
  * @return int current status code
- * @throws \Cake\Core\Exception\Exception When an unknown status code is reached.
+ * @throws \InvalidArgumentException When an unknown status code is reached.
  */
 	public function statusCode($code = null) {
 		if ($code === null) {
 			return $this->_status;
 		}
 		if (!isset($this->_statusCodes[$code])) {
-			throw new Exception('Unknown status code');
+			throw new InvalidArgumentException('Unknown status code');
 		}
 		return $this->_status = $code;
 	}
@@ -666,7 +667,7 @@ class Response {
  *
  * @return mixed associative array of the HTTP codes as keys, and the message
  *    strings as values, or null of the given $code does not exist.
- * @throws \Cake\Core\Exception\Exception If an attempt is made to add an invalid status code
+ * @throws \InvalidArgumentException If an attempt is made to add an invalid status code
  */
 	public function httpCodes($code = null) {
 		if (empty($code)) {
@@ -676,7 +677,7 @@ class Response {
 			$codes = array_keys($code);
 			$min = min($codes);
 			if (!is_int($min) || $min < 100 || max($codes) > 999) {
-				throw new Exception('Invalid status code');
+				throw new InvalidArgumentException('Invalid status code');
 			}
 			$this->_statusCodes = $code + $this->_statusCodes;
 			return true;

+ 4 - 3
src/Network/Socket.php

@@ -15,6 +15,7 @@
 namespace Cake\Network;
 
 use Cake\Core\InstanceConfigTrait;
+use Cake\Network\Exception\SocketException;
 use Cake\Validation\Validation;
 
 /**
@@ -115,7 +116,7 @@ class Socket {
  * Connect the socket to the given host and port.
  *
  * @return bool Success
- * @throws \Cake\Network\Error\SocketException
+ * @throws \Cake\Network\Exception\SocketException
  */
 	public function connect() {
 		if ($this->connection) {
@@ -151,12 +152,12 @@ class Socket {
 
 		if (!empty($errNum) || !empty($errStr)) {
 			$this->setLastError($errNum, $errStr);
-			throw new Error\SocketException($errStr, $errNum);
+			throw new SocketException($errStr, $errNum);
 		}
 
 		if (!$this->connection && $this->_connectionErrors) {
 			$message = implode("\n", $this->_connectionErrors);
-			throw new Error\SocketException($message, E_WARNING);
+			throw new SocketException($message, E_WARNING);
 		}
 
 		$this->connected = is_resource($this->connection);

+ 4 - 3
tests/TestCase/Console/ConsoleErrorHandlerTest.php

@@ -17,8 +17,9 @@ namespace Cake\Test\TestCase\Console;
 use Cake\Console\ConsoleErrorHandler;
 use Cake\Controller\Error\MissingActionException;
 use Cake\Core\Exception\Exception;
-use Cake\Error;
 use Cake\Log\Log;
+use Cake\Network\Exception\InternalErrorException;
+use Cake\Network\Exception\NotFoundException;
 use Cake\TestSuite\TestCase;
 
 /**
@@ -114,7 +115,7 @@ class ConsoleErrorHandlerTest extends TestCase {
  * @return void
  */
 	public function testError404Exception() {
-		$exception = new Error\NotFoundException('dont use me in cli.');
+		$exception = new NotFoundException('dont use me in cli.');
 
 		$this->stderr->expects($this->once())->method('write')
 			->with($this->stringContains('dont use me in cli.'));
@@ -128,7 +129,7 @@ class ConsoleErrorHandlerTest extends TestCase {
  * @return void
  */
 	public function testError500Exception() {
-		$exception = new Error\InternalErrorException('dont use me in cli.');
+		$exception = new InternalErrorException('dont use me in cli.');
 
 		$this->stderr->expects($this->once())->method('write')
 			->with($this->stringContains('dont use me in cli.'));

+ 13 - 11
tests/TestCase/Error/ExceptionRendererTest.php

@@ -30,6 +30,8 @@ use Cake\Error;
 use Cake\Error\ExceptionRenderer;
 use Cake\Event\Event;
 use Cake\Network\Error\SocketException;
+use Cake\Network\Exception\InternalErrorException;
+use Cake\Network\Exception\NotFoundException;
 use Cake\Network\Request;
 use Cake\ORM\Error\MissingBehaviorException;
 use Cake\Routing\Router;
@@ -125,7 +127,7 @@ class MyCustomExceptionRenderer extends ExceptionRenderer {
  * Exception class for testing app error handlers and custom errors.
  *
  */
-class MissingWidgetThingException extends Error\NotFoundException {
+class MissingWidgetThingException extends NotFoundException {
 }
 
 /**
@@ -238,7 +240,7 @@ class ExceptionRendererTest extends TestCase {
  * @return void
  */
 	public function testConstruction() {
-		$exception = new Error\NotFoundException('Page not found');
+		$exception = new NotFoundException('Page not found');
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 
 		$this->assertInstanceOf('Cake\Controller\ErrorController', $ExceptionRenderer->controller);
@@ -362,7 +364,7 @@ class ExceptionRendererTest extends TestCase {
 		$request = new Request('posts/view/1000');
 		Router::setRequestInfo($request);
 
-		$exception = new Error\NotFoundException('Custom message');
+		$exception = new NotFoundException('Custom message');
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 		$ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', array('statusCode', '_sendHeader'));
 		$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(404);
@@ -381,7 +383,7 @@ class ExceptionRendererTest extends TestCase {
 	public function testerror400OnlyChangingCakeException() {
 		Configure::write('debug', false);
 
-		$exception = new Error\NotFoundException('Custom message');
+		$exception = new NotFoundException('Custom message');
 		$ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception));
 
 		$result = $ExceptionRenderer->render();
@@ -405,7 +407,7 @@ class ExceptionRendererTest extends TestCase {
 		$request = new Request('pages/<span id=333>pink</span></id><script>document.body.style.background = t=document.getElementById(333).innerHTML;window.alert(t);</script>');
 		Router::setRequestInfo($request);
 
-		$exception = new Error\NotFoundException('Custom message');
+		$exception = new NotFoundException('Custom message');
 		$ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception));
 
 		$result = $ExceptionRenderer->render()->body();
@@ -420,7 +422,7 @@ class ExceptionRendererTest extends TestCase {
  * @return void
  */
 	public function testError500Message() {
-		$exception = new Error\InternalErrorException('An Internal Error Has Occurred');
+		$exception = new InternalErrorException('An Internal Error Has Occurred');
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 		$ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', array('statusCode', '_sendHeader'));
 		$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500);
@@ -435,7 +437,7 @@ class ExceptionRendererTest extends TestCase {
  * @return void
  */
 	public function testExceptionResponseHeader() {
-		$exception = new Error\MethodNotAllowedException('Only allowing POST and DELETE');
+		$exception = new MethodNotAllowedException('Only allowing POST and DELETE');
 		$exception->responseHeader(array('Allow: POST, DELETE'));
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 
@@ -628,7 +630,7 @@ class ExceptionRendererTest extends TestCase {
  * @return void
  */
 	public function testRenderExceptionInBeforeRender() {
-		$exception = new Error\NotFoundException('Not there, sorry');
+		$exception = new NotFoundException('Not there, sorry');
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 
 		$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('beforeRender'));
@@ -652,7 +654,7 @@ class ExceptionRendererTest extends TestCase {
  * @return void
  */
 	public function testMissingSubdirRenderSafe() {
-		$exception = new Error\NotFoundException();
+		$exception = new NotFoundException();
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 
 		$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('render'));
@@ -688,7 +690,7 @@ class ExceptionRendererTest extends TestCase {
  * @return void
  */
 	public function testMissingPluginRenderSafe() {
-		$exception = new Error\NotFoundException();
+		$exception = new NotFoundException();
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 
 		$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('render'));
@@ -720,7 +722,7 @@ class ExceptionRendererTest extends TestCase {
  */
 	public function testMissingPluginRenderSafeWithPlugin() {
 		Plugin::load('TestPlugin');
-		$exception = new Error\NotFoundException();
+		$exception = new NotFoundException();
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 
 		$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('render'));

+ 3 - 3
tests/test_app/TestApp/Controller/PagesController.php

@@ -19,7 +19,7 @@
 namespace TestApp\Controller;
 
 use Cake\Core\Configure;
-use Cake\Error;
+use Cake\Network\Exception\NotFoundException;
 use Cake\Utility\Inflector;
 use Cake\View\Error\MissingViewException;
 
@@ -51,7 +51,7 @@ class PagesController extends AppController {
  *
  * @param mixed What page to display
  * @return void
- * @throws Cake\Error\NotFoundException When the view file could not be found
+ * @throws Cake\Network\Exception\NotFoundException When the view file could not be found
  *	or Cake\View\Error\MissingViewException in debug mode.
  */
 	public function display() {
@@ -84,7 +84,7 @@ class PagesController extends AppController {
 			if (Configure::read('debug')) {
 				throw $e;
 			}
-			throw new Error\NotFoundException();
+			throw new NotFoundException();
 		}
 	}