]> git.mxchange.org Git - friendica.git/commitdiff
Add HTTPException class files
authorHypolite Petovan <mrpetovan@gmail.com>
Fri, 24 Nov 2017 04:40:54 +0000 (23:40 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Fri, 24 Nov 2017 04:40:54 +0000 (23:40 -0500)
21 files changed:
src/Network/HTTPException.php [new file with mode: 0644]
src/Network/HTTPException/BadGatewayException.php [new file with mode: 0644]
src/Network/HTTPException/BadRequestException.php [new file with mode: 0644]
src/Network/HTTPException/ConflictException.php [new file with mode: 0644]
src/Network/HTTPException/ExpectationFailedException.php [new file with mode: 0644]
src/Network/HTTPException/ForbiddenException.php [new file with mode: 0644]
src/Network/HTTPException/GatewayTimeoutException.php [new file with mode: 0644]
src/Network/HTTPException/GoneException.php [new file with mode: 0644]
src/Network/HTTPException/ImATeapotException.php [new file with mode: 0644]
src/Network/HTTPException/InternalServerErrorException.php [new file with mode: 0644]
src/Network/HTTPException/LenghtRequiredException.php [new file with mode: 0644]
src/Network/HTTPException/MethodNotAllowedException.php [new file with mode: 0644]
src/Network/HTTPException/NonAcceptableException.php [new file with mode: 0644]
src/Network/HTTPException/NotFoundException.php [new file with mode: 0644]
src/Network/HTTPException/NotImplementedException.php [new file with mode: 0644]
src/Network/HTTPException/PreconditionFailedException.php [new file with mode: 0644]
src/Network/HTTPException/ServiceUnavaiableException.php [new file with mode: 0644]
src/Network/HTTPException/TooManyRequestsException.php [new file with mode: 0644]
src/Network/HTTPException/UnauthorizedException.php [new file with mode: 0644]
src/Network/HTTPException/UnprocessableEntityException.php [new file with mode: 0644]
src/Network/HTTPException/UnsupportedMediaTypeException.php [new file with mode: 0644]

diff --git a/src/Network/HTTPException.php b/src/Network/HTTPException.php
new file mode 100644 (file)
index 0000000..eec4a9c
--- /dev/null
@@ -0,0 +1,23 @@
+<?php\r
+\r
+/**\r
+ * Throwable exceptions to return HTTP status code\r
+ *\r
+ * This list of Exception has be extracted from\r
+ * here http://racksburg.com/choosing-an-http-status-code/\r
+ */\r
+\r
+namespace Friendica\Network;\r
+\r
+use Exception;\r
+\r
+class HTTPException extends Exception {\r
+       var $httpcode = 200;\r
+       var $httpdesc = "";\r
+       public function __construct($message = "", $code = 0, Exception $previous = null) {\r
+               if ($this->httpdesc == "") {\r
+                       $this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', str_replace("Exception","",get_class($this)));\r
+               }\r
+               parent::__construct($message, $code, $previous);\r
+       }\r
+}\r
diff --git a/src/Network/HTTPException/BadGatewayException.php b/src/Network/HTTPException/BadGatewayException.php
new file mode 100644 (file)
index 0000000..1bb8b29
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class BadGatewayException extends HTTPException\r
+{\r
+       var $httpcode = 502;\r
+}\r
diff --git a/src/Network/HTTPException/BadRequestException.php b/src/Network/HTTPException/BadRequestException.php
new file mode 100644 (file)
index 0000000..23e59b3
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class BadRequestException extends HTTPException\r
+{\r
+       var $httpcode = 400;\r
+}\r
diff --git a/src/Network/HTTPException/ConflictException.php b/src/Network/HTTPException/ConflictException.php
new file mode 100644 (file)
index 0000000..b1aef72
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class ConflictException extends HTTPException\r
+{\r
+       var $httpcode = 409;\r
+}\r
diff --git a/src/Network/HTTPException/ExpectationFailedException.php b/src/Network/HTTPException/ExpectationFailedException.php
new file mode 100644 (file)
index 0000000..2b7b1fe
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class ExpectationFailedException extends HTTPException\r
+{\r
+       var $httpcode = 417;\r
+}\r
diff --git a/src/Network/HTTPException/ForbiddenException.php b/src/Network/HTTPException/ForbiddenException.php
new file mode 100644 (file)
index 0000000..75622c4
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class ForbiddenException extends HTTPException\r
+{\r
+       var $httpcode = 403;\r
+}
\ No newline at end of file
diff --git a/src/Network/HTTPException/GatewayTimeoutException.php b/src/Network/HTTPException/GatewayTimeoutException.php
new file mode 100644 (file)
index 0000000..306fbd4
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class GatewayTimeoutException extends HTTPException\r
+{\r
+       var $httpcode = 504;\r
+}\r
diff --git a/src/Network/HTTPException/GoneException.php b/src/Network/HTTPException/GoneException.php
new file mode 100644 (file)
index 0000000..ea844b0
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class GoneException extends HTTPException\r
+{\r
+       var $httpcode = 410;\r
+}\r
diff --git a/src/Network/HTTPException/ImATeapotException.php b/src/Network/HTTPException/ImATeapotException.php
new file mode 100644 (file)
index 0000000..fccf632
--- /dev/null
@@ -0,0 +1,11 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class ImATeapotException extends HTTPException\r
+{\r
+       var $httpcode = 418;\r
+       var $httpdesc = "I'm A Teapot";\r
+}\r
diff --git a/src/Network/HTTPException/InternalServerErrorException.php b/src/Network/HTTPException/InternalServerErrorException.php
new file mode 100644 (file)
index 0000000..09c9694
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class InternalServerErrorException extends HTTPException\r
+{\r
+       var $httpcode = 500;\r
+}\r
diff --git a/src/Network/HTTPException/LenghtRequiredException.php b/src/Network/HTTPException/LenghtRequiredException.php
new file mode 100644 (file)
index 0000000..dd952b0
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class LenghtRequiredException extends HTTPException\r
+{\r
+       var $httpcode = 411;\r
+}\r
diff --git a/src/Network/HTTPException/MethodNotAllowedException.php b/src/Network/HTTPException/MethodNotAllowedException.php
new file mode 100644 (file)
index 0000000..8dce414
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class MethodNotAllowedException extends HTTPException\r
+{\r
+       var $httpcode = 405;\r
+}\r
diff --git a/src/Network/HTTPException/NonAcceptableException.php b/src/Network/HTTPException/NonAcceptableException.php
new file mode 100644 (file)
index 0000000..8705a13
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class NonAcceptableException extends HTTPException\r
+{\r
+       var $httpcode = 406;\r
+}\r
diff --git a/src/Network/HTTPException/NotFoundException.php b/src/Network/HTTPException/NotFoundException.php
new file mode 100644 (file)
index 0000000..bd4f615
--- /dev/null
@@ -0,0 +1,9 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class NotFoundException extends HTTPException {\r
+       var $httpcode = 404;\r
+}\r
diff --git a/src/Network/HTTPException/NotImplementedException.php b/src/Network/HTTPException/NotImplementedException.php
new file mode 100644 (file)
index 0000000..74bc8ad
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class NotImplementedException extends HTTPException\r
+{\r
+       var $httpcode = 501;\r
+}\r
diff --git a/src/Network/HTTPException/PreconditionFailedException.php b/src/Network/HTTPException/PreconditionFailedException.php
new file mode 100644 (file)
index 0000000..b0f4e71
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class PreconditionFailedException extends HTTPException\r
+{\r
+       var $httpcode = 412;\r
+}\r
diff --git a/src/Network/HTTPException/ServiceUnavaiableException.php b/src/Network/HTTPException/ServiceUnavaiableException.php
new file mode 100644 (file)
index 0000000..0dd2125
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class ServiceUnavaiableException extends HTTPException\r
+{\r
+       var $httpcode = 503;\r
+}\r
diff --git a/src/Network/HTTPException/TooManyRequestsException.php b/src/Network/HTTPException/TooManyRequestsException.php
new file mode 100644 (file)
index 0000000..c21b223
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class TooManyRequestsException extends HTTPException\r
+{\r
+       var $httpcode = 429;\r
+}\r
diff --git a/src/Network/HTTPException/UnauthorizedException.php b/src/Network/HTTPException/UnauthorizedException.php
new file mode 100644 (file)
index 0000000..79e6114
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class UnauthorizedException extends HTTPException\r
+{\r
+       var $httpcode = 401;\r
+}\r
diff --git a/src/Network/HTTPException/UnprocessableEntityException.php b/src/Network/HTTPException/UnprocessableEntityException.php
new file mode 100644 (file)
index 0000000..9d92778
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class UnprocessableEntityException extends HTTPException\r
+{\r
+       var $httpcode = 422;\r
+}\r
diff --git a/src/Network/HTTPException/UnsupportedMediaTypeException.php b/src/Network/HTTPException/UnsupportedMediaTypeException.php
new file mode 100644 (file)
index 0000000..e730493
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+\r
+namespace Friendica\Network\HTTPException;\r
+\r
+use Friendica\Network\HTTPException;\r
+\r
+class UnsupportedMediaTypeException extends HTTPException\r
+{\r
+       var $httpcode = 415;\r
+}\r