|
5 | 5 | use App\Mail\ExceptionOccured;
|
6 | 6 | use Illuminate\Auth\AuthenticationException;
|
7 | 7 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
8 |
| -use Illuminate\Http\Request; |
9 | 8 | use Illuminate\Http\Response;
|
10 | 9 | use Illuminate\Support\Facades\Log;
|
11 | 10 | use Illuminate\Support\Facades\Mail;
|
12 |
| -use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler; |
| 11 | +use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer; |
| 12 | +use Symfony\Component\ErrorHandler\Exception\FlattenException; |
13 | 13 | use Throwable;
|
14 | 14 |
|
15 | 15 | class Handler extends ExceptionHandler
|
@@ -117,14 +117,11 @@ protected function unauthenticated($request, AuthenticationException $exception)
|
117 | 117 | public function sendEmail(Throwable $exception): void
|
118 | 118 | {
|
119 | 119 | try {
|
120 |
| - $content['message'] = $exception->getMessage(); |
121 |
| - $content['file'] = $exception->getFile(); |
122 |
| - $content['line'] = $exception->getLine(); |
123 |
| - $content['trace'] = $exception->getTrace(); |
124 |
| - $content['url'] = request()->url(); |
125 |
| - $content['body'] = request()->all(); |
126 |
| - $content['ip'] = request()->ip(); |
127 |
| - Mail::send(new ExceptionOccured($content)); |
| 120 | + $e = FlattenException::createFromThrowable($exception); |
| 121 | + $handler = new HtmlErrorRenderer(true); |
| 122 | + $css = $handler->getStylesheet(); |
| 123 | + $content = $handler->getBody($e); |
| 124 | + Mail::send(new ExceptionOccured($content, $css)); |
128 | 125 | } catch (Throwable $exception) {
|
129 | 126 | Log::error($exception);
|
130 | 127 | }
|
|
0 commit comments