1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace OpenSearch\Exception;
6:
7: use OpenSearch\Common\Exceptions\OpenSearchException;
8:
9: /**
10: * Exception thrown when an HTTP error occurs.
11: *
12: * @phpstan-consistent-constructor
13: * @phpstan-ignore class.implementsDeprecatedInterface
14: */
15: class HttpException extends \RuntimeException implements HttpExceptionInterface, OpenSearchException
16: {
17: public function __construct(
18: protected readonly int $statusCode,
19: string $message = '',
20: protected readonly array $headers = [],
21: int $code = 0,
22: ?\Throwable $previous = null,
23: ) {
24: parent::__construct($message, $code, $previous);
25: }
26:
27: public function getStatusCode(): int
28: {
29: return $this->statusCode;
30: }
31:
32: public function getHeaders(): array
33: {
34: return $this->headers;
35: }
36:
37: }
38: