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     * @param string        $message
29     * @param Request|null  $request
30     * @param Response|null $response
31     */
32    public function __construct(string $message, Request $request = null, Response $response = null)
33    {
34        $this->_request = $request;
35        $this->_response = $response;
36
37        parent::__construct($message);
38    }
39
40    /**
41     * Returns request object.
42     *
43     * @return Request|null Request object
44     */
45    public function getRequest()
46    {
47        return $this->_request;
48    }
49
50    /**
51     * Returns response object.
52     *
53     * @return Response|null Response object
54     */
55    public function getResponse()
56    {
57        return $this->_response;
58    }
59}
60