File tree Expand file tree Collapse file tree 5 files changed +135
-4
lines changed Expand file tree Collapse file tree 5 files changed +135
-4
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3
+ HttpImATeapotException.php - Part of the php-exceptions project.
4
+
5
+ © - Jitesoft
6
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7
+ namespace Jitesoft \Exceptions \Http \Client ;
8
+
9
+ use Jitesoft \Exceptions \Http \HttpException ;
10
+ use Jitesoft \Exceptions \Http \Server \HttpNotImplementedException ;
11
+ use Throwable ;
12
+
13
+ /**
14
+ * Class HttpImATeapotException
15
+ *
16
+ * Client http exception which is thrown when server is a coffee brewer hence can't make tea.
17
+ *
18
+ * This is a standardized joke, the http error is sometimes used to indicate that something is not
19
+ * fully implemented (in which case @see HttpNotImplementedException would be preferable.
20
+ */
21
+ class HttpImATeapotException extends HttpException {
22
+
23
+ /**
24
+ * HttpImATeapotException constructor.
25
+ *
26
+ * @param string $message
27
+ * @param int $code
28
+ * @param Throwable|null $previous
29
+ */
30
+ public function __construct (
31
+ string $ message = "I'm a teapot. " ,
32
+ int $ code = 418 ,
33
+ ?Throwable $ previous = null
34
+ ) {
35
+ parent ::__construct ($ message , $ code , $ previous );
36
+ }
37
+
38
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3
+ HttpToEarlyException.php - Part of the php-exceptions project.
4
+
5
+ © - Jitesoft
6
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7
+ namespace Jitesoft \Exceptions \Http \Client ;
8
+
9
+ use Jitesoft \Exceptions \Http \HttpException ;
10
+ use Throwable ;
11
+
12
+ /**
13
+ * Class HttptoEarlyException
14
+ *
15
+ * Client http exception which is used to indicate that the server is unwilling
16
+ * to risk processing the request that might be replayed.
17
+ *
18
+ * This is an experimental http status code which might change.
19
+ */
20
+ class HttpToEarlyException extends HttpException {
21
+
22
+ /**
23
+ * HttpToEarlyException constructor.
24
+ *
25
+ * @param string $message
26
+ * @param int $code
27
+ * @param Throwable|null $previous
28
+ */
29
+ public function __construct (
30
+ string $ message = 'To early. ' ,
31
+ int $ code = 425 ,
32
+ ?Throwable $ previous = null
33
+ ) {
34
+ parent ::__construct ($ message , $ code , $ previous );
35
+ }
36
+
37
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3
+ HttpUnavailableForLegalReasonsException.php - Part of the php-exceptions project.
4
+
5
+ © - Jitesoft
6
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7
+ namespace Jitesoft \Exceptions \Http \Client ;
8
+
9
+ use Jitesoft \Exceptions \Http \HttpException ;
10
+ use Throwable ;
11
+
12
+ /**
13
+ * Class HttpUnavailableForLegalReasonsException
14
+ *
15
+ * Client http exception thrown when a requested resource is unavailable
16
+ * due to legal reasons hence can't be served.
17
+ */
18
+ class HttpUnavailableForLegalReasonsException extends HttpException {
19
+
20
+ private ?string $ reason ;
21
+
22
+ /**
23
+ * Reason for unavailability.
24
+ *
25
+ * @return string|null
26
+ */
27
+ public function getReason (): ?string {
28
+ return $ this ->reason ;
29
+ }
30
+
31
+ /**
32
+ * HttpUnavailableForLegalReasonsException constructor.
33
+ *
34
+ * @param string $message
35
+ * @param string|null $reason
36
+ * @param int $code
37
+ * @param Throwable|null $previous
38
+ */
39
+ public function __construct (
40
+ string $ message = 'Unavailable for Legal Reasons. ' ,
41
+ ?string $ reason = null ,
42
+ int $ code = 451 ,
43
+ ?Throwable $ previous = null
44
+ ) {
45
+ parent ::__construct ($ message , $ code , $ previous );
46
+
47
+ $ this ->reason = $ reason ;
48
+ }
49
+
50
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3
+ HttpBadGatewayException.php - Part of the php-exceptions project.
2
4
5
+ © - Jitesoft
6
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
3
7
namespace Jitesoft \Exceptions \Http \Server ;
4
8
5
9
use Jitesoft \Exceptions \Http \HttpException ;
@@ -21,7 +25,7 @@ class HttpBadGatewayException extends HttpException {
21
25
* @param Throwable|null $previous
22
26
*/
23
27
public function __construct (
24
- string $ message = " Bad Gateway. " ,
28
+ string $ message = ' Bad Gateway. ' ,
25
29
int $ code = 502 ,
26
30
?Throwable $ previous = null
27
31
) {
Original file line number Diff line number Diff line change 18
18
* to retry the request after the given time.
19
19
*/
20
20
class HttpServiceUnavailableException extends HttpException {
21
-
22
21
protected ?int $ retryAfter ;
23
22
24
23
/**
@@ -39,12 +38,15 @@ public function getRetryAfter(): ?int {
39
38
* @param Throwable|null $previous
40
39
*/
41
40
public function __construct (
42
- string $ message =
43
- " Service is currently not able to handle the request. " ,
41
+ string $ message
42
+ = ' Service is currently not able to handle the request. ' ,
44
43
int $ code = 503 ,
45
44
?int $ retryAfter = null ,
46
45
?Throwable $ previous = null
47
46
) {
48
47
parent ::__construct ($ message , $ code , $ previous );
48
+
49
+ $ this ->retryAfter = $ retryAfter ;
49
50
}
51
+
50
52
}
You can’t perform that action at this time.
0 commit comments