Skip to content

Commit

Permalink
Add regex to catch errors without file/line information
Browse files Browse the repository at this point in the history
  • Loading branch information
aglunndexcom committed Feb 24, 2023
1 parent 1087b0c commit e6b55e6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async function main(input, output) {

// We only handle the format without --pretty right now
const UGLY_REGEX = /^(?<file>.+?)\((?<line>\d+),(?<col>\d+)\): error (?<code>\S+?): (?<message>.+)$/;
const ERROR_WITHOUT_FILE_REGEX = /error (?<code>\S+?): (?<message>.+)$/;

/**
* @returns {Parser}
Expand All @@ -58,15 +59,24 @@ function newParser() {
const errors = [];
function parse(line) {
const match = UGLY_REGEX.exec(line);
const errorWithoutFileMatch = ERROR_WITHOUT_FILE_REGEX.exec(line);

if (match) {
errors.push({
filename: match.groups.file,
line: Number(match.groups.line),
col: Number(match.groups.col),
code: match.groups.code,
message: match.groups.message
})
return;
message: match.groups.message,
});
} else if (errorWithoutFileMatch) {
errors.push({
code: errorWithoutFileMatch.groups.code,
col: 'N/A',
filename: 'N/A',
line: 'N/A',
message: errorWithoutFileMatch.groups.message,
});
}
}
return {errors, parse};
Expand Down

0 comments on commit e6b55e6

Please sign in to comment.