Refactored error logging for better debugging information.
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user