1 | <?php declare(strict_types=1); |
||
10 | final class ExceptionFactory |
||
11 | { |
||
12 | const STATUS_CODE_EXCEPTION_MAP = [ |
||
13 | /** |
||
14 | * 1xx codes |
||
15 | */ |
||
16 | 100 => ContinueException::class, |
||
17 | 101 => SwitchingProtocolsException::class, |
||
18 | 102 => ProcessingException::class, |
||
19 | |||
20 | /** |
||
21 | * 2xx codes |
||
22 | */ |
||
23 | 200 => OKException::class, |
||
24 | 201 => CreatedException::class, |
||
25 | 202 => AcceptedException::class, |
||
26 | 203 => NonAuthoritativeInformationException::class, |
||
27 | 204 => NoContentException::class, |
||
28 | 205 => ResetContentException::class, |
||
29 | 206 => PartialContentException::class, |
||
30 | 207 => MultiStatusException::class, |
||
31 | 208 => AlreadyReportedException::class, |
||
32 | 226 => IMUsedException::class, |
||
33 | |||
34 | /** |
||
35 | * 3xx codes |
||
36 | */ |
||
37 | 300 => MultiChoicesException::class, |
||
38 | 301 => MovedPermanentlyException::class, |
||
39 | 302 => FoundException::class, |
||
40 | 303 => SeeOtherException::class, |
||
41 | 304 => NotModifiedException::class, |
||
42 | 305 => UseProxyException::class, |
||
43 | 306 => SwitchProxyException::class, |
||
44 | 307 => TemporaryRedirectException::class, |
||
45 | 308 => PermanentRedirectException::class, |
||
46 | |||
47 | /** |
||
48 | * 4xx codes |
||
49 | */ |
||
50 | 400 => BadRequestException::class, |
||
51 | 401 => UnauthorizedException::class, |
||
52 | 402 => PaymentRequiredException::class, |
||
53 | 403 => ForbiddenException::class, |
||
54 | 404 => NotFoundException::class, |
||
55 | 405 => MethodNotAllowedException::class, |
||
56 | 406 => NotAcceptableException::class, |
||
57 | 407 => ProxyAuthenticationRequiredException::class, |
||
58 | 408 => RequestTimeoutException::class, |
||
59 | 409 => ConflictException::class, |
||
60 | 410 => GoneException::class, |
||
61 | 411 => LengthRequiredException::class, |
||
62 | 412 => PreconditionFailedException::class, |
||
63 | 413 => PayloadTooLargeException::class, |
||
64 | 414 => URITooLongException::class, |
||
65 | 415 => UnsupportedMediaTypeException::class, |
||
66 | 416 => RangeNotSatisfiableException::class, |
||
67 | 417 => ExpectationFailedException::class, |
||
68 | 418 => ImATeapotException::class, |
||
69 | 421 => MisdirectedRequestException::class, |
||
70 | 422 => UnprocessableEntityException::class, |
||
71 | 423 => LockedException::class, |
||
72 | 424 => FailedDependencyException::class, |
||
73 | 426 => UpgradeRequiredException::class, |
||
74 | 428 => PreconditionRequiredException::class, |
||
75 | 429 => TooManyRequestsException::class, |
||
76 | 431 => RequestHeaderFieldsTooLargeException::class, |
||
77 | 451 => UnavailableForLegalReasonsException::class, |
||
78 | |||
79 | /** |
||
80 | * 5xx codes |
||
81 | */ |
||
82 | 500 => InternalServerErrorException::class, |
||
83 | 501 => NotImplementedException::class, |
||
84 | 502 => BadGatewayException::class, |
||
85 | 503 => ServiceUnavailableException::class, |
||
86 | 504 => GatewayTimeoutException::class, |
||
87 | 505 => HTTPVersionNotSupportedException::class, |
||
88 | 506 => VariantAlsoNegotiatesException::class, |
||
89 | 507 => InsufficientStorageException::class, |
||
90 | 508 => LoopDetectedException::class, |
||
91 | 510 => NotExtendedException::class, |
||
92 | 511 => NetworkAuthenticationRequiredException::class, |
||
93 | |||
94 | /** |
||
95 | * IIS (Unofficial) |
||
96 | * |
||
97 | * Excluding the 451 as it conflicts with the official 451 code. |
||
98 | */ |
||
99 | 440 => Unofficial\IIS\LoginTimeoutException::class, |
||
100 | 449 => Unofficial\IIS\RetryWithException::class, |
||
101 | |||
102 | /** |
||
103 | * Cloudflare (Unofficial) |
||
104 | */ |
||
105 | 520 => Unofficial\Cloudflare\UnknownErrorException::class, |
||
106 | 521 => Unofficial\Cloudflare\WebServerIsDownException::class, |
||
107 | 522 => Unofficial\Cloudflare\ConnectionTimedOutException::class, |
||
108 | 523 => Unofficial\Cloudflare\OriginIsUnreachableException::class, |
||
109 | 524 => Unofficial\Cloudflare\ATimeoutOccurredException::class, |
||
110 | 525 => Unofficial\Cloudflare\SSLHandshakeFailedException::class, |
||
111 | 526 => Unofficial\Cloudflare\InvalidSSLCertificateException::class, |
||
112 | 527 => Unofficial\Cloudflare\RailgunErrorException::class, |
||
113 | ]; |
||
114 | |||
115 | 71 | public static function create(ResponseInterface $response, CoreException $previousException) |
|
120 | } |
||
121 |