Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Map unexepected errors to first line (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jan 24, 2017
1 parent fd09d3f commit bc49402
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/goCheck.ts
Expand Up @@ -55,22 +55,34 @@ function runTool(args: string[], cwd: string, severity: string, useStdErr: boole
outputChannel.appendLine(['Finished running tool:', cmd, ...args].join(' '));

let ret: ICheckResult[] = [];
let unexpectedOutput = false;
let atleastSingleMatch = false;
for (let i = 0; i < lines.length; i++) {
if (lines[i][0] === '\t' && ret.length > 0) {
ret[ret.length - 1].msg += '\n' + lines[i];
continue;
}
let match = /^([^:]*: )?((.:)?[^:]*):(\d+)(:(\d+)?)?:(?:\w+:)? (.*)$/.exec(lines[i]);
if (!match) {
if (printUnexpectedOutput) outputChannel.appendLine(lines[i]);
if (printUnexpectedOutput && useStdErr && stderr) unexpectedOutput = true;
continue;
}
atleastSingleMatch = true;
let [_, __, file, ___, lineStr, ____, charStr, msg] = match;
let line = +lineStr;
file = path.resolve(cwd, file);
ret.push({ file, line, msg, severity });
outputChannel.appendLine(`${file}:${line}: ${msg}`);
}
if (!atleastSingleMatch && unexpectedOutput && vscode.window.activeTextEditor) {
outputChannel.appendLine(stderr);
ret.push({
file: vscode.window.activeTextEditor.document.fileName,
line: 1,
msg: stderr,
severity: 'error'
});
}
outputChannel.appendLine('');
resolve(ret);
} catch (e) {
Expand Down

0 comments on commit bc49402

Please sign in to comment.