|
4 | 4 |
|
5 | 5 | namespace HttpSoft\ErrorHandler; |
6 | 6 |
|
| 7 | +use HttpSoft\Response\ResponseStatusCodeInterface; |
7 | 8 | use Psr\Http\Message\ResponseInterface; |
8 | 9 | use Psr\Http\Message\ServerRequestInterface; |
9 | 10 | use Throwable; |
10 | 11 |
|
11 | | -interface ErrorResponseGeneratorInterface |
| 12 | +interface ErrorResponseGeneratorInterface extends ResponseStatusCodeInterface |
12 | 13 | { |
| 14 | + /** |
| 15 | + * Map of error HTTP status code and reason phrases. |
| 16 | + * |
| 17 | + * @link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml |
| 18 | + */ |
| 19 | + public const ERROR_PHRASES = [ |
| 20 | + // Client Errors 4xx |
| 21 | + self::STATUS_BAD_REQUEST => 'Bad Request', |
| 22 | + self::STATUS_UNAUTHORIZED => 'Unauthorized', |
| 23 | + self::STATUS_PAYMENT_REQUIRED => 'Payment Required', |
| 24 | + self::STATUS_FORBIDDEN => 'Forbidden', |
| 25 | + self::STATUS_NOT_FOUND => 'Not Found', |
| 26 | + self::STATUS_METHOD_NOT_ALLOWED => 'Method Not Allowed', |
| 27 | + self::STATUS_NOT_ACCEPTABLE => 'Not Acceptable', |
| 28 | + self::STATUS_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required', |
| 29 | + self::STATUS_REQUEST_TIMEOUT => 'Request Timeout', |
| 30 | + self::STATUS_CONFLICT => 'Conflict', |
| 31 | + self::STATUS_GONE => 'Gone', |
| 32 | + self::STATUS_LENGTH_REQUIRED => 'Length Required', |
| 33 | + self::STATUS_PRECONDITION_FAILED => 'Precondition Failed', |
| 34 | + self::STATUS_PAYLOAD_TOO_LARGE => 'Payload Too Large', |
| 35 | + self::STATUS_URI_TOO_LONG => 'URI Too Long', |
| 36 | + self::STATUS_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type', |
| 37 | + self::STATUS_RANGE_NOT_SATISFIABLE => 'Range Not Satisfiable', |
| 38 | + self::STATUS_EXPECTATION_FAILED => 'Expectation Failed', |
| 39 | + self::STATUS_IM_A_TEAPOT => 'I\'m a teapot', |
| 40 | + self::STATUS_MISDIRECTED_REQUEST => 'Misdirected Request', |
| 41 | + self::STATUS_UNPROCESSABLE_ENTITY => 'Unprocessable Entity', |
| 42 | + self::STATUS_LOCKED => 'Locked', |
| 43 | + self::STATUS_FAILED_DEPENDENCY => 'Failed Dependency', |
| 44 | + self::STATUS_TOO_EARLY => 'Too Early', |
| 45 | + self::STATUS_UPGRADE_REQUIRED => 'Upgrade Required', |
| 46 | + self::STATUS_PRECONDITION_REQUIRED => 'Precondition Required', |
| 47 | + self::STATUS_TOO_MANY_REQUESTS => 'Too Many Requests', |
| 48 | + self::STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large', |
| 49 | + self::STATUS_UNAVAILABLE_FOR_LEGAL_REASONS => 'Unavailable For Legal Reasons', |
| 50 | + // Server Errors 5xx |
| 51 | + self::STATUS_INTERNAL_SERVER_ERROR => 'Internal Server Error', |
| 52 | + self::STATUS_NOT_IMPLEMENTED => 'Not Implemented', |
| 53 | + self::STATUS_BAD_GATEWAY => 'Bad Gateway', |
| 54 | + self::STATUS_SERVICE_UNAVAILABLE => 'Service Unavailable', |
| 55 | + self::STATUS_GATEWAY_TIMEOUT => 'Gateway Timeout', |
| 56 | + self::STATUS_VERSION_NOT_SUPPORTED => 'HTTP Version Not Supported', |
| 57 | + self::STATUS_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates', |
| 58 | + self::STATUS_INSUFFICIENT_STORAGE => 'Insufficient Storage', |
| 59 | + self::STATUS_LOOP_DETECTED => 'Loop Detected', |
| 60 | + self::STATUS_NOT_EXTENDED => 'Not Extended', |
| 61 | + self::STATUS_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required', |
| 62 | + ]; |
| 63 | + |
13 | 64 | /** |
14 | 65 | * Generates an instance of `Psr\Http\Message\ResponseInterface` with information about the handled error. |
15 | 66 | * |
|
0 commit comments