Commit baf594c0 authored by Timon Stampfli's avatar Timon Stampfli

Merge branch 'provide-some-debug-information' into 'master'

providing a debug log for compilation

See merge request !12
parents 4202b0df 41f9a4b1
Pipeline #5662 passed with stages
in 1 minute
......@@ -5389,9 +5389,9 @@
"dev": true
},
"typescript": {
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz",
"integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==",
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz",
"integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==",
"dev": true
},
"uc.micro": {
......
......@@ -76,13 +76,14 @@ export class HelperBinaryResultReceiver {
processResult(this: HelperBinaryResultReceiver, res: string) {
let parsed = checkServerResponseTyped(JSON.parse(res));
if (parsed === null) {
throw Error("invalid package received");
this.store.handleError(
"Downloading dependencies",
"Downloaded a invalid compiler bundle",
Error("invalid package received")
);
}
let [binarypath, samplename, result] = parsed;
let taskname = fspathToTasknameOrError(
this.store,
binarypath
);
let taskname = fspathToTasknameOrError(this.store, binarypath);
this.store.addExecutionResult(taskname, samplename, result);
}
}
......@@ -38,11 +38,16 @@ export class Runner {
try {
await fs.readFile(compilerPath);
} catch {
} catch (err) {
vscode.window.showErrorMessage(
"Compiler executable not found at expected path"
);
return;
this.store.logError(
"compilation",
`file at compilerpath '${compilerPath}' not found`,
err
);
resolve("Failed");
}
let compileTaskDefinition = {
label: "build " + taskname + " development",
......@@ -76,8 +81,18 @@ export class Runner {
try {
await fs.unlink(soitaskFiles.binaryFsPath);
} catch (err) {
if (err.code !== "ENOENT") {
throw err;
if (err.code === "ENOENT") {
this.store.logInfo(
"compilation",
`compiled binary '${compilerPath}' not found`,
err
);
} else {
this.store.handleError(
"compilation",
`deleting binary '${soitaskFiles.binaryFsPath}' failed`,
err
);
}
}
......@@ -92,6 +107,7 @@ export class Runner {
try {
await vscode.tasks.executeTask(compileTask);
} catch (err) {
this.store.logError("compilation", "executing task failed", err);
resolve("Failed");
}
......@@ -102,6 +118,11 @@ export class Runner {
resolve("Success");
});
} catch (err) {
this.store.logError(
"compilation",
`reading binary '${soitaskFiles.binaryFsPath}" failed`,
err
);
if (err.code !== "EEXIST") {
resolve("Failed");
}
......@@ -110,6 +131,7 @@ export class Runner {
});
setTimeout(() => {
this.store.logError("compilation", `timed out compilation`);
resolve("Failed");
}, 10000);
});
......@@ -292,12 +314,16 @@ export class Runner {
vscode.window.showErrorMessage(
"Unknown error occured when checking binary: " + err.toString()
);
throw err;
} else {
vscode.window.showErrorMessage(
"The binary to debug does not exist" + err.toString()
);
}
this.store.handleError(
"debug",
`binary path '${soitaskFiles.binaryFsPath}'does not exist`,
err
);
}
let workspaceFolder = vscode.workspace.getWorkspaceFolder(
vscode.Uri.file(soitaskFiles.binaryFsPath)
......
......@@ -26,8 +26,11 @@ export class Store {
fileChangeSubscribers: (() => void)[];
allSampleChangeSubscribers: (() => void)[];
sampleUpdateSubscriber: ((s: string) => void)[];
private channel: vscode.OutputChannel;
constructor(context: vscode.ExtensionContext) {
this.channel = vscode.window.createOutputChannel("soicode");
context.subscriptions.push(this.channel);
this.soicodeExtensionDataPath = context.globalStoragePath;
this.soicodeExtensionImagePath = context.asAbsolutePath("images");
this.soicodeExtensionDistPath = context.asAbsolutePath("dist");
......@@ -40,6 +43,47 @@ export class Store {
this.subscribeStoreToEvents(context);
}
handleError(this: Store, location: string, info: string, err: Error): never {
this.channel.appendLine(`#### Error ${location} ####`);
this.channel.appendLine(info);
this.channel.appendLine("error name:");
this.channel.appendLine(err.name);
this.channel.appendLine("message:");
this.channel.appendLine(err.message);
if (err.stack !== undefined) {
this.channel.appendLine("stack trace");
this.channel.appendLine(err.stack);
}
this.channel.show();
throw err;
}
logInfo(this: Store, location: string, info: string, err?: Error) {
this.channel.appendLine(`#### info at [${location}] ####`);
this.channel.appendLine(info);
if (err !== undefined) {
this.channel.appendLine(err.name);
this.channel.appendLine("message:");
this.channel.appendLine(err.message);
if (err.stack !== undefined) {
this.channel.appendLine("stack trace");
this.channel.appendLine(err.stack);
}
}
}
logError(this: Store, location: string, info: string, err?: Error) {
this.channel.appendLine(`#### error at [${location}] ####`);
this.channel.appendLine(info);
if (err !== undefined) {
this.channel.appendLine(err.name);
this.channel.appendLine("message:");
this.channel.appendLine(err.message);
if (err.stack !== undefined) {
this.channel.appendLine("stack trace");
this.channel.appendLine(err.stack);
}
}
}
addExecutionResult(
this: Store,
taskname: string,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment