[RTOP-26] catch errors on file upload and compile program

This commit is contained in:
lucasbutzke
2025-07-21 20:21:14 -03:00
parent 46cbc34b4c
commit 60709a94d8
2 changed files with 11 additions and 5 deletions
+3 -3
View File
@@ -137,9 +137,9 @@ class runtime:
else:
# No debug info... probably a program generated from the old editor. Use the blank debug info just to compile the program
f = open('./core/debug.blank', "r")
c_debug = f.read()
f.close()
with open('./core/debug.blank', "r") as f:
c_debug = f.read()
f.close()
# Write c_debug file
with open('./core/debug.cpp', "w") as f:
+8 -2
View File
@@ -59,11 +59,17 @@ def restapi_callback_get(argument: str, data: dict) -> dict:
elif argument == "compilation-status":
status = openplc_runtime.compilation_status_str
if status == "":
return {"compilation-status": "No compilation in progress"}
return {"compilation-status": status}
elif argument == "compilation-logs":
logs = openplc_runtime.compilation_status()
return {"compilation-logs": logs}
try:
logs = openplc_runtime.compilation_status()
return {"compilation-logs": logs}
except Exception as e:
logger.error(f"Error retrieving compilation logs: {e}")
return {"error": str(e)}
elif argument == "status":
return {"current_status": "operational", "details": data}