Refactored error logging for better debugging information.

This commit is contained in:
Benjamin Arntzen (aider)
2024-06-27 07:39:56 +01:00
parent 80835c65af
commit e67dfbc23f
+11 -1
View File
@@ -117,7 +117,17 @@ function parseLogLines(data) {
const parsedLog = JSON.parse(jsonLine);
validLogs.push(parsedLog);
} catch (parseError) {
console.error(`Error parsing log line at index ${index}: ${parseError.message}`);
if (index === 0) {
console.error(`Error parsing log line at index ${index}: ${parseError.message}`);
console.error(`Log line: ${line}`);
const position = parseError.message.match(/position (\d+)/);
if (position) {
const pos = parseInt(position[1], 10);
console.error(`Character at position ${pos}: ${line.charAt(pos)}`);
}
} else {
console.error(`Error parsing log line at index ${index}: ${parseError.message}`);
}
}
}
});