Browse Source

Better error handling

dev/git-series/gccdum
Matt Godbolt 6 years ago
parent
commit
6d2959f8f1
  1. 13
      lib/compile-handler.js
  2. 3
      lib/utils.js

13
lib/compile-handler.js

@ -29,6 +29,7 @@ var child_process = require('child_process'),
quote = require('shell-quote'),
_ = require('underscore-node'),
logger = require('./logger').logger,
utils = require('./utils'),
CompilationEnvironment = require('./compilation-env').CompilationEnvironment;
temp.track();
@ -163,9 +164,17 @@ function CompileHandler(gccProps, compilerProps) {
}
},
function (error) {
logger.error("Error: " + error.stack || error);
logger.error("Error", error);
if (typeof(error) !== "string") {
error = "Internal Compiler Explorer error: " + error.stack || error;
if (error.code) {
if (typeof(error.stderr) === "string") {
error.stdout = utils.parseOutput(error.stdout);
error.stderr = utils.parseOutput(error.stderr);
}
res.end(JSON.stringify(error));
return;
}
error = "Internal Compiler Explorer error: " + (error.stack || error);
}
res.end(JSON.stringify({code: -1, stderr: [{text: error}]}));
}

3
lib/utils.js

@ -53,7 +53,8 @@ function parseOutput(lines, inputFilename) {
var re = /^<source>[:(]([0-9]+)(:[0-9]+:)?[):]*\s*(.*)/;
var result = [];
eachLine(lines, function (line) {
line = line.trim().replace(inputFilename, '<source>');
line = line.trim();
if (inputFilename) line = line.replace(inputFilename, '<source>');
if (line !== "" && line.indexOf("fixme:") !== 0) {
var lineObj = {text: line};
var match = line.match(re);

Loading…
Cancel
Save