1: <?php declare(strict_types=1);
2:
3: namespace Salient\Curler\Exception;
4:
5: use Psr\Http\Message\RequestInterface;
6: use Salient\Contract\Http\HttpResponseInterface;
7: use Throwable;
8:
9: /**
10: * @api
11: */
12: abstract class AbstractResponseException extends AbstractRequestException
13: {
14: protected HttpResponseInterface $Response;
15:
16: /**
17: * @param array<string,mixed> $data
18: */
19: public function __construct(
20: string $message,
21: RequestInterface $request,
22: HttpResponseInterface $response,
23: array $data = [],
24: ?Throwable $previous = null
25: ) {
26: $this->Response = $response;
27:
28: parent::__construct($message, $request, $data, $previous);
29: }
30:
31: /**
32: * @inheritDoc
33: */
34: public function getResponse(): HttpResponseInterface
35: {
36: return $this->Response;
37: }
38:
39: /**
40: * @inheritDoc
41: */
42: public function getMetadata(): array
43: {
44: return [
45: 'Response' => (string) $this->Response,
46: ] + parent::getMetadata();
47: }
48: }
49: