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