ErrorResponseException::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @author Dmitry Gladyshev <[email protected]>
4
 * @date 26/08/2016 14:24
5
 */
6
7
namespace Yandex\Direct\Exception;
8
9
/**
10
 * Class ErrorResponseException
11
 * @package Yandex\Direct\Exception
12
 */
13
class ErrorResponseException extends Exception
14
{
15
    /**
16
     * @var int
17
     */
18
    protected $requestId;
19
20
    /**
21
     * @var string
22
     */
23
    protected $details;
24
25
    /**
26
     * @param string $message
27
     * @param string $details
28
     * @param int $code
29
     * @param int $requestId
30
     * @param \Exception $previous
31
     */
32
    public function __construct($message, $details = '', $code = 0, $requestId = 0, \Exception $previous = null)
33
    {
34
        $this->details = $details;
35
        $this->requestId = $requestId;
36
        parent::__construct($message, $code, $previous);
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function __toString()
43
    {
44
        $str = 'Exception ' . __CLASS__ . " code {$this->code} with message '{$this->message}' in `{$this->file}`" . PHP_EOL;
45
        $str .= 'Details: ' . $this->details . PHP_EOL;
46
        $str .= 'Stack trace:' . PHP_EOL . $this->getTraceAsString();
47
        return $str;
48
    }
49
}
50