magicRecentExceptionsEnricher function
Enricher: emits magicRecentExceptions: <Type> at <file.dart>:<line>,...
for up to 3 most recent records in TelescopeStore.recentExceptions.
Each entry is the ExceptionRecord.exceptionType followed by the
file:line extracted from the first stack-trace frame. When the
stackTrace is null or no file.dart:line token can be parsed from
it, the entry collapses to the type alone (no trailing at ...
suffix).
Returns null when the telescope buffer is empty or the telescope classpath is not present.
Implementation
String? magicRecentExceptionsEnricher(Element element, RefRegistry refs) {
final List<ExceptionRecord>? records = _safeReadRecentExceptions();
if (records == null || records.isEmpty) return null;
final List<String> parts = records
.map((r) {
final String? location = _firstStackLocation(r.stackTrace);
return location == null
? r.exceptionType
: '${r.exceptionType} at $location';
})
.toList(growable: false);
return 'magicRecentExceptions: ${parts.join(',')}';
}