JavaProxiedException::getJvmStackTrace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Jasper report integration for PHP
7
 *
8
 * @link      https://github.com/belgattitude/soluble-jasper
9
 * @author    Vanvelthem Sébastien
10
 * @copyright Copyright (c) 2017-2019 Vanvelthem Sébastien
11
 * @license   MIT
12
 */
13
14
namespace Soluble\Jasper\Exception;
15
16
use Soluble\Japha\Bridge\Exception\JavaException;
17
18
class JavaProxiedException extends RuntimeException implements JavaProxiedExceptionInterface
19
{
20
    /**
21
     * @var JavaException
22
     */
23
    private $javaException;
24
25 10
    public function __construct(JavaException $javaException, ?string $msg = null, ?int $code = null)
26
    {
27 10
        $this->javaException = $javaException;
28 10
        $message             = sprintf(
29 10
            '%s[%s]: %s (%s)',
30 10
            $msg !== null ? "$msg. " : '',
31 10
            $javaException->getJavaClassName(),
32 10
            $javaException->getMessage(),
33 10
            $javaException->getCause()
34
        );
35 10
        parent::__construct($message, $code ?? $javaException->getCode());
36 10
    }
37
38
    /**
39
     * Return java exception as return by the bridge server.
40
     */
41 1
    public function getJavaException(): JavaException
42
    {
43 1
        return $this->javaException;
44
    }
45
46
    /**
47
     * Return the JVM exception backtrace.
48
     */
49 1
    public function getJvmStackTrace(): string
50
    {
51 1
        return $this->javaException->getStackTrace();
52
    }
53
}
54