Skip to content

Commit

Permalink
fix: let the task update the failure to message
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Sep 4, 2019
1 parent f4808ea commit fa84f2d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/store/modules/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ const mod = {
taskWatcher.update(node._internalId, update);
});
task.onFinish((result, node) => {
// console.log(`Task Finish: ${node.path}`);
if (task.root === node) {
ipcMain.emit('task-successed', node._internalId);
delete nameToTask[key];
Expand All @@ -186,14 +185,20 @@ const mod = {
taskWatcher.status(node._internalId, 'successed');
});
task.onError((error, node) => {
// console.error(`Task Error: ${node.path}`);
// console.error(error);

if (task.root === node) {
ipcMain.emit('task-failed', node._internalId, error);
console.error(`Task [${node.name}] failed.`);
console.error(error);
delete nameToTask[key];
}

let errorMessage;
if (error instanceof Error) {
errorMessage = error.stack;
} else {
errorMessage = JSON.stringify(error, null, 4);
}
taskWatcher.update(node._internalId, { message: errorMessage });
taskWatcher.status(node._internalId, 'failed');
});
if (task.background) {
Expand Down

0 comments on commit fa84f2d

Please sign in to comment.