File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 9
9
# {{ $exception ? $exception -> getLine () : " " } }
10
10
11
11
## Trace :
12
- # {{ $exception ? $exception -> getTraceAsString () : " " } }
12
+ # {{ $exception || $stackTrace ? $stackTrace : " " } }
13
13
</x-mail::message >
Original file line number Diff line number Diff line change @@ -20,8 +20,31 @@ public function __construct($exception)
20
20
21
21
public function build ()
22
22
{
23
+ $ stackTrace = $ this ->formatStackTrace ($ this ->exception );
24
+
23
25
return $ this ->subject (config ('error-mailer.email.subject ' ))
24
26
->markdown ('errorMailer::error ' )
25
- ->with (['exception ' => $ this ->exception ]);
27
+ ->with (['exception ' => $ this ->exception , 'stackTrace ' => $ stackTrace ]);
28
+ }
29
+
30
+ function formatStackTrace ($ exception ) {
31
+ $ trace = $ exception ->getTraceAsString ();
32
+ $ traceLines = explode ("\n" , $ trace );
33
+ $ formattedTrace = [];
34
+
35
+ foreach ($ traceLines as $ line ) {
36
+ // Extraction des informations clés de chaque ligne
37
+ if (preg_match ('/^#(\d+) (.*?):(.*)$/ ' , $ line , $ matches )) {
38
+ $ number = $ matches [1 ];
39
+ $ path = trim ($ matches [2 ]);
40
+ $ detail = trim ($ matches [3 ]);
41
+
42
+ // Formatage de chaque entrée de la stack trace
43
+ $ formattedLine = "### $ number $ path \n$ detail \n" ;
44
+ $ formattedTrace [] = $ formattedLine ;
45
+ }
46
+ }
47
+
48
+ return implode ("\n" , $ formattedTrace );
26
49
}
27
50
}
You can’t perform that action at this time.
0 commit comments