From 6c0efb62e729ea5e8658c1561f630a1b5fff37f4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Dec 2010 13:38:09 -0500 Subject: [PATCH] Adding a base HttpException for all the various HttpExceptions that cake provides, this should make it easier to write concise catch blocks. --- cake/libs/error/exceptions.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cake/libs/error/exceptions.php b/cake/libs/error/exceptions.php index 473b2dbee..961b39c7d 100644 --- a/cake/libs/error/exceptions.php +++ b/cake/libs/error/exceptions.php @@ -19,12 +19,21 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +/** + * Parent class for all of the HTTP related exceptions in CakePHP. + * All HTTP status/error related exceptions should extend this class so + * catch blocks can be specifically typed. + * + * @package cake.libs + */ +class HttpException extends RuntimeException { } + /** * Represents an HTTP 400 error. * * @package cake.libs */ -class BadRequestException extends RuntimeException { +class BadRequestException extends HttpException { /** * Constructor * @@ -44,7 +53,7 @@ class BadRequestException extends RuntimeException { * * @package cake.libs */ -class UnauthorizedException extends RuntimeException { +class UnauthorizedException extends HttpException { /** * Constructor * @@ -64,7 +73,7 @@ class UnauthorizedException extends RuntimeException { * * @package cake.libs */ -class ForbiddenException extends RuntimeException { +class ForbiddenException extends HttpException { /** * Constructor * @@ -84,7 +93,7 @@ class ForbiddenException extends RuntimeException { * * @package cake.libs */ -class NotFoundException extends RuntimeException { +class NotFoundException extends HttpException { /** * Constructor * @@ -104,7 +113,7 @@ class NotFoundException extends RuntimeException { * * @package cake.libs */ -class MethodNotAllowedException extends RuntimeException { +class MethodNotAllowedException extends HttpException { /** * Constructor * @@ -124,7 +133,7 @@ class MethodNotAllowedException extends RuntimeException { * * @package cake.libs */ -class InternalErrorException extends CakeException { +class InternalErrorException extends HttpException { /** * Constructor *