Completed
Push — master ( 45ee30...d2ebdc )
by Bogdan
11s
created

DebugEchoExceptionHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 2
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the pinepain/js-sandbox PHP library.
5
 *
6
 * Copyright (c) 2016-2017 Bogdan Padalko <[email protected]>
7
 *
8
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
9
 *
10
 * For the full copyright and license information, please view the
11
 * LICENSE file that was distributed with this source or visit
12
 * http://opensource.org/licenses/MIT
13
 */
14
15
16
namespace Pinepain\JsSandbox\Specs\ExceptionHandlers;
17
18
19
use Pinepain\JsSandbox\Exceptions\NativeException;
20
use Throwable;
21
use V8\Context;
22
use V8\Isolate;
23
24
25
class DebugEchoExceptionHandler implements ExceptionHandlerInterface
26
{
27
    public function handle(Isolate $isolate, Context $context, Throwable $throwable)
28
    {
29
        $message = 'An internal error occurred: ' . get_class($throwable) . ': ' . $throwable->getMessage() . PHP_EOL . $throwable->getTraceAsString();
30
31
        throw new NativeException($message, 0, $throwable);
32
    }
33
}
34