-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathBookStackExceptionHandlerPage.php
More file actions
41 lines (36 loc) · 1.11 KB
/
BookStackExceptionHandlerPage.php
File metadata and controls
41 lines (36 loc) · 1.11 KB
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
<?php
namespace BookStack\Exceptions;
use BookStack\App\AppVersion;
use Illuminate\Contracts\Foundation\ExceptionRenderer;
class BookStackExceptionHandlerPage implements ExceptionRenderer
{
public function render($throwable)
{
return view('errors.debug', [
'error' => $throwable->getMessage(),
'errorClass' => get_class($throwable),
'trace' => $throwable->getTraceAsString(),
'environment' => $this->getEnvironment(),
])->render();
}
protected function safeReturn(callable $callback, $default = null)
{
try {
return $callback();
} catch (\Exception $e) {
return $default;
}
}
protected function getEnvironment(): array
{
return [
'PHP Version' => phpversion(),
'BookStack Version' => $this->safeReturn(function () {
return AppVersion::get();
}, 'unknown'),
'Theme Configured' => $this->safeReturn(function () {
return config('view.theme');
}) ?? 'None',
];
}
}