summaryrefslogtreecommitdiff
path: root/libs/jsonrpc/src/JsonRPC/Exception/ResponseException.php
blob: e97b4e6b77a84c1df2e8b67af28f7ac9fd9fdce8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

namespace JsonRPC\Exception;

use Exception;

/**
 * Class ResponseException
 *
 * @package JsonRPC\Exception
 * @author  Frederic Guillot
 */
class ResponseException extends RpcCallFailedException
{
    /**
     * A value that contains additional information about the error.
     *
     * @access protected
     * @link http://www.jsonrpc.org/specification#error_object
     * @var mixed
     */
    protected $data;

    /**
     * Constructor
     *
     * @access public
     * @param string    $message  [optional] The Exception message to throw.
     * @param int       $code     [optional] The Exception code.
     * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
     * @param mixed     $data     [optional] A value that contains additional information about the error.
     */
    public function __construct($message = '', $code = 0, Exception $previous = null, $data = null)
    {
        parent::__construct($message, $code, $previous);
        $this->setData($data);
    }

    /**
     * Attach additional information
     *
     * @access public
     * @param mixed $data [optional] A value that contains additional information about the error.
     * @return \JsonRPC\Exception\ResponseException
     */
    public function setData($data = null)
    {
        $this->data = $data;
        return $this;
    }

    /**
     * Get additional information
     *
     * @access public
     * @return mixed|null
     */
    public function getData()
    {
        return $this->data;
    }
}