← All changes
|
src/ai/http-request/domain/exceptions/remote-request-exception.php
+23
-5
27.6
→
trunk
View file →
| @@ -20,18 +20,27 @@ | ||
| 20 | 20 | */ |
| 21 | 21 | private $error_identifier; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | + * The response headers associated with the error, keyed by lower-cased header name. | |
| 25 | + * | |
| 26 | + * @var array<string, string|array<string>> | |
| 27 | + */ | |
| 28 | + private $response_headers; | |
| 29 | + | |
| 30 | + /** | |
| 24 | 31 | * Constructor. |
| 25 | 32 | * |
| 26 | - * @param string $message The error message. | |
| 27 | - * @param int $code The error status code. | |
| 28 | - * @param string $error_identifier The error code identifier, used to identify a type of error. | |
| 29 | - * @param Throwable|null $previous The previously thrown exception. | |
| 33 | + * @param string $message The error message. | |
| 34 | + * @param int $code The error status code. | |
| 35 | + * @param string $error_identifier The error code identifier, used to identify a type of error. | |
| 36 | + * @param Throwable|null $previous The previously thrown exception. | |
| 37 | + * @param array<string, string|array<string>> $response_headers The response headers associated with the error. | |
| 30 | 38 | */ |
| 31 | - public function __construct( $message = '', $code = 0, $error_identifier = '', ?Throwable $previous = null ) { | |
| 39 | + public function __construct( $message = '', $code = 0, $error_identifier = '', ?Throwable $previous = null, array $response_headers = [] ) { | |
| 32 | 40 | parent::__construct( $message, $code, $previous ); |
| 33 | 41 | $this->error_identifier = (string) $error_identifier; |
| 42 | + $this->response_headers = $response_headers; | |
| 34 | 43 | } |
| 35 | 44 | |
| 36 | 45 | /** |
| 37 | 46 | * Returns the error identifier. |
| @@ -39,6 +48,15 @@ | ||
| 39 | 48 | * @return string The error identifier. |
| 40 | 49 | */ |
| 41 | 50 | public function get_error_identifier(): string { |
| 42 | 51 | return $this->error_identifier; |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Returns the response headers associated with the error, keyed by lower-cased header name. | |
| 56 | + * | |
| 57 | + * @return array<string, string|array<string>> The response headers. | |
| 58 | + */ | |
| 59 | + public function get_response_headers(): array { | |
| 60 | + return $this->response_headers; | |
| 43 | 61 | } |
| 44 | 62 | } |