parseSessionHeaderLine function
Parses the header line of a session file into its SessionHeader.
Public for the windowed reader (session_chunk_reader.dart), which
parses only the lines it reads. Throws SessionException on a bad line.
Implementation
SessionHeader parseSessionHeaderLine(String line, String filePath) {
Object? parsed;
try {
parsed = jsonDecode(line);
} on Object catch (error) {
_invalidSession(
filePath,
'first line is not a valid session header',
error,
);
}
if (parsed is! Map<String, dynamic>) {
_invalidSession(filePath, 'first line is not a valid session header');
}
try {
return SessionHeader.fromJson(parsed);
} on FormatException catch (error) {
_invalidSession(filePath, error.message, error);
}
}