Fix error handling in tests

This commit is contained in:
Nilay Majorwar 2022-01-22 18:49:34 +05:30
parent 22939dabf5
commit dbccab5244

View File

@ -29,10 +29,10 @@ export const executeProgram = async <T>(
): Promise<{ output: string; rendererState: T }> => { ): Promise<{ output: string; rendererState: T }> => {
const controller = new ExecutionController(engine); const controller = new ExecutionController(engine);
controller.prepare(code, input); controller.prepare(code, input);
return new Promise((resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
let output = ""; let output = "";
controller.executeAll({ const { error } = await controller.executeAll({
interval: 0, interval: 0,
onResult: (res) => { onResult: (res) => {
if (res.output) output += res.output; if (res.output) output += res.output;
@ -41,6 +41,7 @@ export const executeProgram = async <T>(
} }
}, },
}); });
if (error) reject(error);
} catch (error) { } catch (error) {
reject(error); reject(error);
} }