1313use Spatie \LaravelIgnition \Exceptions \ViewException as IgnitionViewException ;
1414use SplFileObject ;
1515use stdClass ;
16+ use Symfony \Component \ErrorHandler \Error \FatalError ;
1617use Throwable ;
1718
1819use function array_is_list ;
3536 */
3637final class ExceptionSensor
3738{
39+ private const int VERSION = 3 ;
40+
3841 /**
3942 * @var array<string, SplFileObject|null>
4043 */
@@ -56,6 +59,10 @@ public function __construct(
5659 */
5760 public function __invoke (Throwable $ e , ?bool $ handled ): array
5861 {
62+ if ($ e instanceof FatalError) {
63+ return $ this ->fatalError ($ e );
64+ }
65+
5966 $ nowMicrotime = $ this ->clock ->microtime ();
6067 [$ file , $ line ] = $ this ->location ->forException ($ e );
6168 $ normalizedException = match ($ e ->getPrevious ()) {
@@ -76,7 +83,7 @@ public function __invoke(Throwable $e, ?bool $handled): array
7683 $ this ->executionState ->exceptions ++;
7784
7885 return [
79- 'v ' => 3 ,
86+ 'v ' => self :: VERSION ,
8087 't ' => 'exception ' ,
8188 'timestamp ' => $ nowMicrotime ,
8289 'deploy ' => $ this ->executionState ->deploy ,
@@ -100,6 +107,35 @@ public function __invoke(Throwable $e, ?bool $handled): array
100107 ];
101108 }
102109
110+ private function fatalError (FatalError $ e )
111+ {
112+ $ file = $ this ->location ->normalizeFile ($ e ->getFile ());
113+
114+ return [
115+ 'v ' => self ::VERSION ,
116+ 't ' => 'exception ' ,
117+ 'timestamp ' => $ this ->clock ->microtime (),
118+ 'deploy ' => $ this ->executionState ->deploy ,
119+ 'server ' => $ this ->executionState ->server ,
120+ '_group ' => hash ('xxh128 ' , $ e ::class.', ' .$ e ->getCode ().', ' .$ file .', ' .$ e ->getLine ()),
121+ 'trace_id ' => $ this ->executionState ->trace ,
122+ 'execution_source ' => $ this ->executionState ->source ,
123+ 'execution_id ' => '' ,
124+ 'execution_preview ' => $ this ->executionState ->executionPreview ,
125+ 'execution_stage ' => $ this ->executionState ->stage ,
126+ 'user ' => $ this ->executionState ->user ->resolvedUserId (),
127+ 'class ' => $ e ::class,
128+ 'file ' => Str::tinyText ($ file ),
129+ 'line ' => $ e ->getLine (),
130+ 'message ' => Str::text ($ e ->getMessage ()),
131+ 'code ' => (string ) $ e ->getCode (),
132+ 'trace ' => '' ,
133+ 'handled ' => false ,
134+ 'php_version ' => $ this ->executionState ->phpVersion ,
135+ 'laravel_version ' => $ this ->executionState ->laravelVersion ,
136+ ];
137+ }
138+
103139 private function wasManuallyReported (Throwable $ e ): bool
104140 {
105141 foreach (debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS , limit: 20 ) as $ frame ) {
0 commit comments