|null */ private ?array $errorPayload; /** * @param array|null $errorPayload */ public function __construct( string $message, ResponseInterface $response, int $statusCode, string $errorCode, ?array $errorPayload = null ) { parent::__construct($message, $statusCode); $this->response = $response; $this->statusCode = $statusCode; $this->errorCode = $errorCode; $this->errorPayload = $errorPayload; } /** * Returns the raw PSR-7 response that triggered the exception. */ public function getResponse(): ResponseInterface { return $this->response; } /** * Returns the HTTP status code from the failed response. */ public function statusCode(): int { return $this->statusCode; } /** * Returns the normalized API error code. */ public function errorCode(): string { return $this->errorCode; } /** * Returns the decoded error payload when the response body matched a known JSON error shape. * * @return array|null */ public function errorPayload(): ?array { return $this->errorPayload; } }