|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Lenevor Framework |
|
5
|
|
|
* |
|
6
|
|
|
* LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the new BSD license that is bundled |
|
9
|
|
|
* with this package in the file license.md. |
|
10
|
|
|
* It is also available through the world-wide-web at this URL: |
|
11
|
|
|
* https://lenevor.com/license |
|
12
|
|
|
* If you did not receive a copy of the license and are unable to |
|
13
|
|
|
* obtain it through the world-wide-web, please send an email |
|
14
|
|
|
* to [email protected] so we can send you a copy immediately. |
|
15
|
|
|
* |
|
16
|
|
|
* @package Lenevor |
|
17
|
|
|
* @subpackage Base |
|
18
|
|
|
* @link https://lenevor.com |
|
19
|
|
|
* @copyright Copyright (c) 2019 - 2023 Alexander Campo <[email protected]> |
|
20
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace Syscodes\Components\Core\Exceptions\Debugging; |
|
24
|
|
|
|
|
25
|
|
|
use Syscodes\Components\Debug\GDebug; |
|
26
|
|
|
use Syscodes\Components\Contracts\Core\ExceptionRender; |
|
27
|
|
|
|
|
28
|
|
|
use function take; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Creates a new Debug exception render instance. |
|
32
|
|
|
*/ |
|
33
|
|
|
class DebugExceptionRender implements ExceptionRender |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Renders the given exception as HTML. |
|
37
|
|
|
* |
|
38
|
|
|
* @param \Throwable $exception |
|
39
|
|
|
* |
|
40
|
|
|
* @return string |
|
41
|
|
|
*/ |
|
42
|
|
|
public function render($exception): string |
|
43
|
|
|
{ |
|
44
|
|
|
return take(new GDebug, function ($debug) { |
|
45
|
|
|
|
|
46
|
|
|
$debug->appendHandler($this->DebugHandler()); |
|
47
|
|
|
|
|
48
|
|
|
$debug->writeToOutput(false); |
|
49
|
|
|
|
|
50
|
|
|
$debug->allowQuit(false); |
|
51
|
|
|
|
|
52
|
|
|
})->handleException($exception); |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Get the Debug handler for the application. |
|
57
|
|
|
* |
|
58
|
|
|
* @return \Syscodes\Components\Debug\Handlers\MainHandler |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function DebugHandler() |
|
61
|
|
|
{ |
|
62
|
|
|
return (new DebugHandler)->initDebug(); |
|
63
|
|
|
} |
|
64
|
|
|
} |