From 48e34b2dbde909cad61f618b2ea8a2ea286012af Mon Sep 17 00:00:00 2001
From: Daniel Friesel <daniel.friesel@uos.de>
Date: Thu, 29 Oct 2020 14:01:21 +0100
Subject: EnergyTraceWithTimer: Gracefully handle errors in a single
 measurement run

---
 lib/loader.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'lib')

diff --git a/lib/loader.py b/lib/loader.py
index a319c94..8aecbe0 100644
--- a/lib/loader.py
+++ b/lib/loader.py
@@ -1789,9 +1789,16 @@ class EnergyTraceWithTimer(EnergyTraceWithLogicAnalyzer):
         for tr in traces:
             for t in tr["trace"]:
                 # print(t["online_aggregates"]["duration"][offline_index])
-                timestamps.append(
-                    timestamps[-1] + t["online_aggregates"]["duration"][offline_index]
-                )
+                try:
+                    timestamps.append(
+                        timestamps[-1]
+                        + t["online_aggregates"]["duration"][offline_index]
+                    )
+                except IndexError:
+                    self.errors.append(
+                        f"""offline_index {offline_index} missing in trace {tr["id"]}"""
+                    )
+                    return list()
 
         # print(timestamps)
 
-- 
cgit v1.2.3