|
2 | 2 |
|
3 | 3 | namespace Binarcode\LaravelDeveloper\Telescope; |
4 | 4 |
|
| 5 | +use Illuminate\Support\Arr; |
| 6 | +use Laravel\Telescope\ExceptionContext; |
| 7 | +use Laravel\Telescope\IncomingExceptionEntry; |
| 8 | +use Laravel\Telescope\Telescope; |
5 | 9 | use Throwable; |
6 | 10 |
|
7 | 11 | class TelescopeException |
8 | 12 | { |
9 | | - public static function recordException(Throwable $exception, $message = null): void |
| 13 | + public static function record(Throwable $exception, $message = null): void |
10 | 14 | { |
11 | | - if (!class_exists('Laravel\\Telescope\\Telescope') || |
12 | | - !class_exists('Laravel\\Telescope\\IncomingExceptionEntry') || |
13 | | - !class_exists('Laravel\\Telescope\\ExceptionContext') |
14 | | - ) { |
15 | | - return; |
16 | | - } |
17 | | - |
18 | 15 | $trace = collect($exception->getTrace())->map(function ($item) { |
19 | 16 | return Arr::only($item, ['file', 'line']); |
20 | 17 | })->toArray(); |
21 | 18 |
|
22 | | - Telescope::recordException( |
23 | | - IncomingExceptionEntry::make($exception, [ |
24 | | - 'class' => get_class($exception), |
25 | | - 'file' => $exception->getFile(), |
26 | | - 'line' => $exception->getLine(), |
27 | | - 'message' => $message ?? $exception->getMessage(), |
28 | | - 'context' => null, |
29 | | - 'trace' => $trace, |
30 | | - 'line_preview' => ExceptionContext::get($exception), |
31 | | - ]) |
32 | | - ); |
| 19 | + try { |
| 20 | + Telescope::recordException( |
| 21 | + IncomingExceptionEntry::make($exception, [ |
| 22 | + 'class' => get_class($exception), |
| 23 | + 'file' => $exception->getFile(), |
| 24 | + 'line' => $exception->getLine(), |
| 25 | + 'message' => $message ?? $exception->getMessage(), |
| 26 | + 'context' => null, |
| 27 | + 'trace' => $trace, |
| 28 | + 'line_preview' => ExceptionContext::get($exception), |
| 29 | + ]) |
| 30 | + ); |
| 31 | + } catch (Throwable $e) { |
| 32 | + } |
33 | 33 | } |
34 | 34 | } |
0 commit comments