]> git.mxchange.org Git - friendica.git/blob - include/HTTPExceptions.php
Issue 3857: There is the possibility of a bad handling of dislikes
[friendica.git] / include / HTTPExceptions.php
1 <?php
2 /**
3  * Throwable exceptions to return HTTP status code
4  *
5  * This list of Exception has be extracted from
6  * here http://racksburg.com/choosing-an-http-status-code/
7  */
8
9 class HTTPException extends Exception {
10         var $httpcode = 200;
11         var $httpdesc = "";
12         public function __construct($message="", $code = 0, Exception $previous = null) {
13                 if ($this->httpdesc=="") {
14                         $this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', str_replace("Exception","",get_class($this)));
15                 }
16                 parent::__construct($message, $code, $previous);
17         }
18 }
19
20 // 4xx
21 class TooManyRequestsException extends HTTPException {
22         var $httpcode = 429;
23 }
24
25 class UnauthorizedException extends HTTPException {
26         var $httpcode = 401;
27 }
28
29 class ForbiddenException extends HTTPException {
30         var $httpcode = 403;
31 }
32
33 class NotFoundException extends HTTPException {
34         var $httpcode = 404;
35 }
36
37 class GoneException extends HTTPException {
38         var $httpcode = 410;
39 }
40
41 class MethodNotAllowedException extends HTTPException {
42         var $httpcode = 405;
43 }
44
45 class NonAcceptableException extends HTTPException {
46         var $httpcode = 406;
47 }
48
49 class LenghtRequiredException extends HTTPException {
50         var $httpcode = 411;
51 }
52
53 class PreconditionFailedException extends HTTPException {
54         var $httpcode = 412;
55 }
56
57 class UnsupportedMediaTypeException extends HTTPException {
58         var $httpcode = 415;
59 }
60
61 class ExpetationFailesException extends HTTPException {
62         var $httpcode = 417;
63 }
64
65 class ConflictException extends HTTPException {
66         var $httpcode = 409;
67 }
68
69 class UnprocessableEntityException extends HTTPException {
70         var $httpcode = 422;
71 }
72
73 class ImATeapotException extends HTTPException {
74         var $httpcode = 418;
75         var $httpdesc = "I'm A Teapot";
76 }
77
78 class BadRequestException extends HTTPException {
79         var $httpcode = 400;
80 }
81
82 // 5xx
83
84 class ServiceUnavaiableException extends HTTPException {
85         var $httpcode = 503;
86 }
87
88 class BadGatewayException extends HTTPException {
89         var $httpcode = 502;
90 }
91
92 class GatewayTimeoutException extends HTTPException {
93         var $httpcode = 504;
94 }
95
96 class NotImplementedException extends HTTPException {
97         var $httpcode = 501;
98 }
99
100 class InternalServerErrorException extends HTTPException {
101         var $httpcode = 500;
102 }
103
104
105