Add phpdoc for HttpException and subclasses.

This commit is contained in:
PJ Dietz 2014-07-13 10:26:01 -04:00
parent aec8bcca4a
commit ae9fbaa709
1 changed files with 53 additions and 8 deletions

View File

@ -1,39 +1,84 @@
<?php <?php
/**
* HttpException and its subclasses provides exceptions that correspond to HTTP
* error status codes. The most common are included, but you may create
* additional subclasses if needed by subclassing HttpException.
*
* The HttpException classes are intended to be used with Handler subclasses
* (pjdietz\WellRESTed\Handler). Handler::getResponse() catches HttpException
* exceptions and converts them to responses using the exception's code as the
* HTTP status code and the exception's message as the response body.
*
* @author PJ Dietz <pj@pjdietz.com>
* @copyright Copyright 2014 by PJ Dietz
* @license MIT
*/
namespace pjdietz\WellRESTed\Exceptions; namespace pjdietz\WellRESTed\Exceptions;
/**
* Base exception for HTTP-related errors. Also represents a 500 Internal Server error.
*/
class HttpException extends WellRESTedException class HttpException extends WellRESTedException
{ {
/** @var int HTTP Status Code */
protected $code = 500; protected $code = 500;
/** @var string Default description for the error */
protected $message = "500 Internal Server Error"; protected $message = "500 Internal Server Error";
} }
/**
* Represents a 400 Bad Request error.
*/
class BadRequestException extends HttpException class BadRequestException extends HttpException
{ {
/** @var int HTTP Status Code */
protected $code = 400; protected $code = 400;
/** @var string Default description for the error */
protected $message = "400 Bad Request"; protected $message = "400 Bad Request";
} }
class ForbiddenException extends HttpException /**
{ * Represents a 401 Unauthorization error.
protected $code = 401; */
protected $message = "401 Forbidden";
}
class UnauthorizedException extends HttpException class UnauthorizedException extends HttpException
{ {
protected $code = 403; /** @var int HTTP Status Code */
protected $message = "403 Unauthorized"; protected $code = 401;
/** @var string Default description for the error */
protected $message = "401 Unauthorized";
} }
/**
* Represents a 403 Forbidden error.
*/
class ForbiddenException extends HttpException
{
/** @var int HTTP Status Code */
protected $code = 403;
/** @var string Default description for the error */
protected $message = "403 Forbidden";
}
/**
* Represents a 404 Not Found error.
*/
class NotFoundException extends HttpException class NotFoundException extends HttpException
{ {
/** @var int HTTP Status Code */
protected $code = 404; protected $code = 404;
/** @var string Default description for the error */
protected $message = "404 Not Found"; protected $message = "404 Not Found";
} }
/**
* Represents a 409 Conflict error.
*/
class ConflictException extends HttpException class ConflictException extends HttpException
{ {
/** @var int HTTP Status Code */
protected $code = 409; protected $code = 409;
/** @var string Default description for the error */
protected $message = "409 Conflict"; protected $message = "409 Conflict";
} }