make(ExceptionHandler::class) ->reportable(function (Throwable $e) { $level = $this->mapExceptionToLogLevel($e); ExceptionOccurred::dispatch($e, $level, $e->getMessage(), []); }); } private function mapExceptionToLogLevel(Throwable $exception): LogLevelEnum { return match (true) { $exception instanceof \Error => LogLevelEnum::CRITICAL, $exception instanceof \RuntimeException => LogLevelEnum::ERROR, $exception instanceof \InvalidArgumentException => LogLevelEnum::WARNING, default => LogLevelEnum::ERROR, }; } }