Remove code parameter from HTTPException constructor
- Remove duplicate HTTPException->httpcode class variable
This commit is contained in:
parent
07cb887885
commit
8eba329111
24 changed files with 60 additions and 29 deletions
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* Throwable exceptions to return HTTP status code
|
||||
*
|
||||
* This list of Exception has be extracted from
|
||||
* This list of Exception has been extracted from
|
||||
* here http://racksburg.com/choosing-an-http-status-code/
|
||||
*/
|
||||
|
||||
|
@ -11,17 +11,17 @@ namespace Friendica\Network;
|
|||
|
||||
use Exception;
|
||||
|
||||
class HTTPException extends Exception
|
||||
abstract class HTTPException extends Exception
|
||||
{
|
||||
var $httpcode = 200;
|
||||
var $httpdesc = "";
|
||||
public $httpdesc = '';
|
||||
|
||||
public function __construct($message = '', $code = 0, Exception $previous = null)
|
||||
public function __construct($message = '', Exception $previous = null)
|
||||
{
|
||||
if ($this->httpdesc == '') {
|
||||
parent::__construct($message, $this->code, $previous);
|
||||
|
||||
if (empty($this->httpdesc)) {
|
||||
$classname = str_replace('Exception', '', str_replace('Friendica\Network\HTTPException\\', '', get_class($this)));
|
||||
$this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', $classname);
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
|
|
10
src/Network/HTTPException/AcceptedException.php
Normal file
10
src/Network/HTTPException/AcceptedException.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Network\HTTPException;
|
||||
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class AcceptedException extends HTTPException
|
||||
{
|
||||
protected $code = 202;
|
||||
}
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class BadGatewayException extends HTTPException
|
||||
{
|
||||
var $httpcode = 502;
|
||||
protected $code = 502;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class BadRequestException extends HTTPException
|
||||
{
|
||||
var $httpcode = 400;
|
||||
protected $code = 400;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class ConflictException extends HTTPException
|
||||
{
|
||||
var $httpcode = 409;
|
||||
protected $code = 409;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class ExpectationFailedException extends HTTPException
|
||||
{
|
||||
var $httpcode = 417;
|
||||
protected $code = 417;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class ForbiddenException extends HTTPException
|
||||
{
|
||||
var $httpcode = 403;
|
||||
protected $code = 403;
|
||||
}
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class GatewayTimeoutException extends HTTPException
|
||||
{
|
||||
var $httpcode = 504;
|
||||
protected $code = 504;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class GoneException extends HTTPException
|
||||
{
|
||||
var $httpcode = 410;
|
||||
protected $code = 410;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class ImATeapotException extends HTTPException
|
||||
{
|
||||
var $httpcode = 418;
|
||||
protected $code = 418;
|
||||
var $httpdesc = "I'm A Teapot";
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class InternalServerErrorException extends HTTPException
|
||||
{
|
||||
var $httpcode = 500;
|
||||
protected $code = 500;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class LenghtRequiredException extends HTTPException
|
||||
{
|
||||
var $httpcode = 411;
|
||||
protected $code = 411;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class MethodNotAllowedException extends HTTPException
|
||||
{
|
||||
var $httpcode = 405;
|
||||
protected $code = 405;
|
||||
}
|
||||
|
|
10
src/Network/HTTPException/NoContentException.php
Normal file
10
src/Network/HTTPException/NoContentException.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Network\HTTPException;
|
||||
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class NoContentException extends HTTPException
|
||||
{
|
||||
protected $code = 204;
|
||||
}
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class NonAcceptableException extends HTTPException
|
||||
{
|
||||
var $httpcode = 406;
|
||||
protected $code = 406;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Friendica\Network\HTTPException;
|
|||
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class NotFoundException extends HTTPException {
|
||||
var $httpcode = 404;
|
||||
class NotFoundException extends HTTPException
|
||||
{
|
||||
protected $code = 404;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class NotImplementedException extends HTTPException
|
||||
{
|
||||
var $httpcode = 501;
|
||||
protected $code = 501;
|
||||
}
|
||||
|
|
10
src/Network/HTTPException/OKException.php
Normal file
10
src/Network/HTTPException/OKException.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Network\HTTPException;
|
||||
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class OKException extends HTTPException
|
||||
{
|
||||
protected $code = 200;
|
||||
}
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class PreconditionFailedException extends HTTPException
|
||||
{
|
||||
var $httpcode = 412;
|
||||
protected $code = 412;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class ServiceUnavaiableException extends HTTPException
|
||||
{
|
||||
var $httpcode = 503;
|
||||
protected $code = 503;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class TooManyRequestsException extends HTTPException
|
||||
{
|
||||
var $httpcode = 429;
|
||||
protected $code = 429;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class UnauthorizedException extends HTTPException
|
||||
{
|
||||
var $httpcode = 401;
|
||||
protected $code = 401;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class UnprocessableEntityException extends HTTPException
|
||||
{
|
||||
var $httpcode = 422;
|
||||
protected $code = 422;
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
class UnsupportedMediaTypeException extends HTTPException
|
||||
{
|
||||
var $httpcode = 415;
|
||||
protected $code = 415;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue