1<?php
2
3namespace Elastica\Exception;
4
5use Elastica\Request;
6use Elastica\Response;
7
8/**
9 * Connection exception.
10 *
11 * @author Nicolas Ruflin <spam@ruflin.com>
12 */
13class ConnectionException extends \RuntimeException implements ExceptionInterface
14{
15    /**
16     * @var Request|null Request object
17     */
18    protected $_request;
19
20    /**
21     * @var Response|null Response object
22     */
23    protected $_response;
24
25    /**
26     * Construct Exception.
27     */
28    public function __construct(string $message, ?Request $request = null, ?Response $response = null)
29    {
30        $this->_request = $request;
31        $this->_response = $response;
32
33        parent::__construct($message);
34    }
35
36    /**
37     * Returns request object.
38     *
39     * @return Request|null Request object
40     */
41    public function getRequest()
42    {
43        return $this->_request;
44    }
45
46    /**
47     * Returns response object.
48     *
49     * @return Response|null Response object
50     */
51    public function getResponse()
52    {
53        return $this->_response;
54    }
55}
56