1 | <?php |
||
10 | final class HttpException extends \RuntimeException |
||
11 | { |
||
12 | /** |
||
13 | * @var Request |
||
14 | */ |
||
15 | private $request; |
||
16 | |||
17 | /** |
||
18 | * @var Response |
||
19 | */ |
||
20 | private $response; |
||
21 | |||
22 | const STATUS_400 = 'Bad Request'; |
||
23 | const STATUS_401 = 'Unauthorized'; |
||
24 | const STATUS_402 = 'Payment Required'; |
||
25 | const STATUS_403 = 'Forbidden'; |
||
26 | const STATUS_404 = 'Not Found'; |
||
27 | const STATUS_405 = 'Method Not Allowed'; |
||
28 | const STATUS_406 = 'Not Acceptable'; |
||
29 | const STATUS_407 = 'Proxy Authentication Required'; |
||
30 | const STATUS_408 = 'Request Time-out'; |
||
31 | const STATUS_409 = 'Conflict'; |
||
32 | const STATUS_410 = 'Gone'; |
||
33 | const STATUS_411 = 'Length Required'; |
||
34 | const STATUS_412 = 'Precondition Failed'; |
||
35 | const STATUS_413 = 'Request Entity Too Large'; |
||
36 | const STATUS_414 = 'Request-URL Too Long'; |
||
37 | const STATUS_415 = 'Unsupported Media Type'; |
||
38 | const STATUS_416 = 'Requested range not satisfiable'; |
||
39 | const STATUS_417 = 'Expectation Failed'; |
||
40 | const STATUS_418 = 'I’m a teapot'; |
||
41 | const STATUS_420 = 'Policy Not Fulfilled'; |
||
42 | const STATUS_421 = 'Misdirected Request'; |
||
43 | const STATUS_422 = 'Unprocessable Entity'; |
||
44 | const STATUS_423 = 'Locked'; |
||
45 | const STATUS_424 = 'Failed Dependency'; |
||
46 | const STATUS_425 = 'Unordered Collection'; |
||
47 | const STATUS_426 = 'Upgrade Required'; |
||
48 | const STATUS_428 = 'Precondition Required'; |
||
49 | const STATUS_429 = 'Too Many Requests'; |
||
50 | const STATUS_431 = 'Request Header Fields Too Large'; |
||
51 | const STATUS_451 = 'Unavailable For Legal Reasons'; |
||
52 | const STATUS_444 = 'No Response'; |
||
53 | const STATUS_449 = 'The request should be retried after doing the appropriate action'; |
||
54 | |||
55 | const STATUS_500 = 'Internal Server Error'; |
||
56 | const STATUS_501 = 'Not Implemented'; |
||
57 | const STATUS_502 = 'Bad Gateway'; |
||
58 | const STATUS_503 = 'Service Unavailable'; |
||
59 | const STATUS_504 = 'Gateway Time-out'; |
||
60 | const STATUS_505 = 'HTTP Version not supported'; |
||
61 | const STATUS_506 = 'Variant Also Negotiates'; |
||
62 | const STATUS_507 = 'Insufficient Storage'; |
||
63 | const STATUS_508 = 'Loop Detected'; |
||
64 | const STATUS_509 = 'Bandwidth Limit Exceeded'; |
||
65 | const STATUS_510 = 'Not Extended'; |
||
66 | const STATUS_511 = 'Network Authentication Required'; |
||
67 | |||
68 | /** |
||
69 | * @param Request $request |
||
70 | * @param Response $response |
||
71 | * @param int $status |
||
72 | * @param string|null $message |
||
73 | * |
||
74 | * @return HttpException |
||
75 | */ |
||
76 | public static function create(Request $request, Response $response, int $status, string $message = null): self |
||
85 | |||
86 | /** |
||
87 | * @param int $status |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | private static function getMessageByStatus(int $status): string |
||
101 | |||
102 | /** |
||
103 | * @return Request |
||
104 | */ |
||
105 | public function getRequest(): Request |
||
109 | |||
110 | /** |
||
111 | * @return Response |
||
112 | */ |
||
113 | public function getResponse(): Response |
||
117 | } |
||
118 |