handle devchat not found error

This commit is contained in:
bobo.yang 2023-05-19 16:12:22 +08:00
parent 94413e6f1f
commit 8dcc4e4a6e
2 changed files with 18 additions and 4 deletions

View File

@ -2,7 +2,7 @@
"name": "devchat", "name": "devchat",
"displayName": "DevChat", "displayName": "DevChat",
"description": "Write prompts, not code", "description": "Write prompts, not code",
"version": "0.0.42", "version": "0.0.45",
"icon": "assets/devchat.png", "icon": "assets/devchat.png",
"publisher": "merico", "publisher": "merico",
"engines": { "engines": {
@ -23,6 +23,7 @@
"dist/*", "dist/*",
"bin/*", "bin/*",
"assets/*", "assets/*",
"tools/*",
"workflows/*", "workflows/*",
"LICENSE", "LICENSE",
"README.md" "README.md"

View File

@ -80,6 +80,18 @@ class DevChat {
reject({ code, stdout, stderr }); reject({ code, stdout, stderr });
} }
}); });
// Add error event listener to handle command not found exception
this.childProcess.on('error', (error: any) => {
if (error.code === 'ENOENT') {
logger.channel()?.error(`Command not found: ${command}`);
logger.channel()?.show();
} else {
logger.channel()?.error(`Error occurred: ${error.message}`);
logger.channel()?.show();
}
reject({ code: error.code, stdout: "", stderr: error.message });
});
}); });
}; };
@ -290,6 +302,7 @@ class DevChat {
}, },
}, (partialResponse: string) => { }); }, (partialResponse: string) => { });
logger.channel()?.info(`Finish devchat with args: ${args.join(" ")}`);
if (stderr) { if (stderr) {
logger.channel()?.error(`Error getting log: ${stderr}`); logger.channel()?.error(`Error getting log: ${stderr}`);
logger.channel()?.show(); logger.channel()?.show();