add error handling

This commit is contained in:
Guille Gutierrez 2022-05-11 07:34:24 -04:00
parent 2030cf5b96
commit 8d3cf3a341
3 changed files with 69 additions and 54 deletions

View File

@ -75,6 +75,11 @@ label {
font-width: bold;
}
.error {
color: red;
font-width: bold;
}
#links a {
color: #0CFF0C;
}

View File

@ -89,6 +89,10 @@ function run_script(script, parameters='') {
document.getElementById('spinner').style.visibility = "hidden"
plot_results()
}
else if (message == '[simulation abort]')
{
document.getElementById('spinner').style.visibility = "hidden"
}
else if (message.substring(0, 4) == 'row:')
{
message = message.replace('row: ', '')
@ -97,6 +101,12 @@ function run_script(script, parameters='') {
heating.push(row[1])
cooling.push(row[2])
}
else if (message.substring(0, 6) == 'error:')
{
message = message.replace('error: ', '')
message = '<label class="error">' + message + '</label>'
document.getElementById('debug').innerHTML = message
}
else if (message.substring(0, 5) == 'info:')
{
message = message.replace('info: ', '')

View File

@ -1,8 +1,8 @@
import sys
from pathlib import Path
import csv
sys.path.append('../libs')
sys.path.append('../hub')
try:
from imports.geometry_factory import GeometryFactory
from imports.construction_factory import ConstructionFactory
from imports.usage_factory import UsageFactory
@ -57,9 +57,9 @@ with open((out_path/ f'{city.name}_out.csv').resolve()) as f:
if ':00:00' in row[0]:
print(f'row: {row[0]}, {row[8]}, {row[9]}')
print(f'info: {idf_file}, {csv_file}, {eso_file}, {area}, {volume}, {obj_file}')
print('[simulation end]')
except Exception as ex:
print('error: ', ex)
print('[simulation abort]')
sys.stdout.flush()