fixed execution errors when generated code used returns

This commit is contained in:
Kolby Nottingham 2023-11-08 19:06:48 -08:00
parent 32810722fb
commit cd26c646b0

View file

@ -74,13 +74,10 @@ export class Coder {
console.log('executing code...\n'); console.log('executing code...\n');
let execution_file = await import('.'+filename); let execution_file = await import('.'+filename);
this.clear(); this.clear();
let success = await execution_file.main(this.agent.bot); await execution_file.main(this.agent.bot);
let message = success ? 'Code await returned successfully.' : 'Code await return failed!'; let msg = 'Code executed successfully.';
if (success) console.log(msg)
console.log(message) return {success: true, message: msg};
else
console.error(message);
return {success, message};
} catch (err) { } catch (err) {
console.error("Code execution triggered catch:" + err); console.error("Code execution triggered catch:" + err);
this.clear(); this.clear();