From 7a966cbe21145de8e8954ece54eba4a9148c613b Mon Sep 17 00:00:00 2001 From: Mishtee Gandhi Date: Thu, 14 Dec 2023 22:32:03 +0530 Subject: [PATCH 1/3] Error messsge for empty code --- ArduinoFrontend/src/app/Libs/Workspace.ts | 148 +++++++++++----------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/ArduinoFrontend/src/app/Libs/Workspace.ts b/ArduinoFrontend/src/app/Libs/Workspace.ts index b2b19fe4..187a6ea3 100644 --- a/ArduinoFrontend/src/app/Libs/Workspace.ts +++ b/ArduinoFrontend/src/app/Libs/Workspace.ts @@ -957,86 +957,90 @@ export class Workspace { for (const arduino of window.scope.ArduinoUno) { toSend[arduino.id] = arduino.code; nameMap[arduino.id] = arduino; - } - - window.printConsole('Compiling Source Code', ConsoleType.INFO); - - if (window.progLang === 0) { - api.compileCodeINO(toSend).subscribe(v => { - const taskid = v.uuid; // Get Compilation id - const temp = setInterval(() => { - api.getHex(taskid).subscribe(hex => { - if (hex.state === 'SUCCESS' && !hex.details.error) { - clearInterval(temp); - let SUCCESS = true; - for (const k in hex.details) { - if (hex.details[k]) { - const d = hex.details[k]; - window.printConsole('For Arduino ' + nameMap[k].name, ConsoleType.INFO); - if (d.output && d.data) { - window.printConsole(d.output, ConsoleType.OUTPUT); - nameMap[k].hex = d.data; + if (arduino.code == "") { + window.printConsole('Error: No Source Code to Compile', ConsoleType.ERROR); + callback(); + } + else { + window.printConsole('Compiling Source Code', ConsoleType.INFO); + if (window.progLang === 0) { + api.compileCodeINO(toSend).subscribe(v => { + const taskid = v.uuid; // Get Compilation id + const temp = setInterval(() => { + api.getHex(taskid).subscribe(hex => { + if (hex.state === 'SUCCESS' && !hex.details.error) { + clearInterval(temp); + let SUCCESS = true; + for (const k in hex.details) { + if (hex.details[k]) { + const d = hex.details[k]; + window.printConsole('For Arduino ' + nameMap[k].name, ConsoleType.INFO); + if (d.output && d.data) { + window.printConsole(d.output, ConsoleType.OUTPUT); + nameMap[k].hex = d.data; + } + if (d.error) { + SUCCESS = false; + window.printConsole(d.error, ConsoleType.ERROR); + } + } } - if (d.error) { - SUCCESS = false; - window.printConsole(d.error, ConsoleType.ERROR); + if (SUCCESS) { + Workspace.startArduino(); } + callback(); + } else if (hex.state === 'FAILED' || hex.details.error) { + clearInterval(temp); + window.printConsole('Failed To Compile: Server Error', ConsoleType.ERROR); + callback(); } - } - if (SUCCESS) { - Workspace.startArduino(); - } - callback(); - } else if (hex.state === 'FAILED' || hex.details.error) { - clearInterval(temp); - window.printConsole('Failed To Compile: Server Error', ConsoleType.ERROR); - callback(); - } + }); + }, 2000); + }, error => { + window.printConsole('Error While Compiling the Source Code.', ConsoleType.ERROR); + console.log(error); + callback(); }); - }, 2000); - }, error => { - window.printConsole('Error While Compiling the Source Code.', ConsoleType.ERROR); - console.log(error); - callback(); - }); - } else if (window.progLang === 1) { - api.compileCodeInlineAssembly(toSend).subscribe(v => { - const taskid = v.uuid; // Get Compilation id - const temp = setInterval(() => { - api.getHex(taskid).subscribe(hex => { - if (hex.state === 'SUCCESS' && !hex.details.error) { - clearInterval(temp); - let SUCCESS = true; - for (const k in hex.details) { - if (hex.details[k]) { - const d = hex.details[k]; - window.printConsole('For Arduino ' + nameMap[k].name, ConsoleType.INFO); - if (d.output && d.data) { - window.printConsole(d.output, ConsoleType.OUTPUT); - nameMap[k].hex = d.data; + } else if (window.progLang === 1) { + api.compileCodeInlineAssembly(toSend).subscribe(v => { + const taskid = v.uuid; // Get Compilation id + const temp = setInterval(() => { + api.getHex(taskid).subscribe(hex => { + if (hex.state === 'SUCCESS' && !hex.details.error) { + clearInterval(temp); + let SUCCESS = true; + for (const k in hex.details) { + if (hex.details[k]) { + const d = hex.details[k]; + window.printConsole('For Arduino ' + nameMap[k].name, ConsoleType.INFO); + if (d.output && d.data) { + window.printConsole(d.output, ConsoleType.OUTPUT); + nameMap[k].hex = d.data; + } + if (d.error) { + SUCCESS = false; + window.printConsole(d.error, ConsoleType.ERROR); + } + } } - if (d.error) { - SUCCESS = false; - window.printConsole(d.error, ConsoleType.ERROR); + if (SUCCESS) { + Workspace.startArduino(); } + callback(); + } else if (hex.state === 'FAILED' || hex.details.error) { + clearInterval(temp); + window.printConsole('Failed To Compile: Server Error', ConsoleType.ERROR); + callback(); } - } - if (SUCCESS) { - Workspace.startArduino(); - } - callback(); - } else if (hex.state === 'FAILED' || hex.details.error) { - clearInterval(temp); - window.printConsole('Failed To Compile: Server Error', ConsoleType.ERROR); - callback(); - } + }); + }, 2000); + }, error => { + window.printConsole('Error While Compiling the Source Code.', ConsoleType.ERROR); + console.log(error); + callback(); }); - }, 2000); - }, error => { - window.printConsole('Error While Compiling the Source Code.', ConsoleType.ERROR); - console.log(error); - callback(); - }); + } + } } } /** From 077b93cee0d1f755a94b982a4258e9a835423fef Mon Sep 17 00:00:00 2001 From: Mishtee Gandhi Date: Fri, 15 Dec 2023 00:09:26 +0530 Subject: [PATCH 2/3] Error messsge for empty code - merge error resolution --- ArduinoFrontend/src/app/Libs/Workspace.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArduinoFrontend/src/app/Libs/Workspace.ts b/ArduinoFrontend/src/app/Libs/Workspace.ts index 187a6ea3..5cb61ad2 100644 --- a/ArduinoFrontend/src/app/Libs/Workspace.ts +++ b/ArduinoFrontend/src/app/Libs/Workspace.ts @@ -957,7 +957,7 @@ export class Workspace { for (const arduino of window.scope.ArduinoUno) { toSend[arduino.id] = arduino.code; nameMap[arduino.id] = arduino; - if (arduino.code == "") { + if (arduino.code === '') { window.printConsole('Error: No Source Code to Compile', ConsoleType.ERROR); callback(); } From aa1d646ce76a4af05f86f0d245a3ab15f624e0f9 Mon Sep 17 00:00:00 2001 From: Mishtee Gandhi Date: Fri, 15 Dec 2023 10:45:06 +0530 Subject: [PATCH 3/3] Error messsge for empty code - merge error resolution --- ArduinoFrontend/src/app/Libs/Workspace.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ArduinoFrontend/src/app/Libs/Workspace.ts b/ArduinoFrontend/src/app/Libs/Workspace.ts index 5cb61ad2..f60ffadc 100644 --- a/ArduinoFrontend/src/app/Libs/Workspace.ts +++ b/ArduinoFrontend/src/app/Libs/Workspace.ts @@ -960,8 +960,7 @@ export class Workspace { if (arduino.code === '') { window.printConsole('Error: No Source Code to Compile', ConsoleType.ERROR); callback(); - } - else { + } else { window.printConsole('Compiling Source Code', ConsoleType.INFO); if (window.progLang === 0) { api.compileCodeINO(toSend).subscribe(v => {