Skip to content

Commit

Permalink
#35: better exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ppebay committed Nov 27, 2024
1 parent c97de9f commit 2c6cfdc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ccm_milp/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ def parse_json(self, data_files: list, verbose: bool):
for task in data_json["phases"][0]["tasks"]:
# Get data
time = task["time"]
entity = task.get("entity")
if entity is None:
try:
entity = task["entity"]
except KeyError:
print (f"*** ERROR: task {task} has no associated entity")
sys.exit(1)
index = entity.get("index")
try:
obj_id = entity["id"]
except:
except KeyError:
try:
obj_id = entity["seq_id"]
except:
except KeyError:
print (f"*** ERROR: entity {entity} neither has an id nor a seq_id")
sys.exit(1)
if task.get("user_defined") is None:
Expand Down

0 comments on commit 2c6cfdc

Please sign in to comment.