From 678db2b00217b4204e15ff2cc32b70f416040cc3 Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Mon, 14 Nov 2022 13:41:05 +0100
Subject: [PATCH] Add logging to the OverflowError in ztplot

The issue where it was first mentioned is https://git.km3net.de/working_groups/daq/-/issues/147
---
 backend/scripts/ztplot.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/backend/scripts/ztplot.py b/backend/scripts/ztplot.py
index 503738f..4c59982 100755
--- a/backend/scripts/ztplot.py
+++ b/backend/scripts/ztplot.py
@@ -203,12 +203,18 @@ class ZTPlot(kp.Module):
             if trig_check(int(trigger_mask))
         ])
 
+        try:
+            dt = datetime.utcfromtimestamp(utc_timestamp)
+        except OverflowError:
+            self.log.critical("OverflowError encountered when converting '%s' to "
+                              "a datetime object." % utc_timestamp)
+            dt = "invalid date"
+
         title = "z-t-Plot for DetID-{0} Run {1}, "  \
                 "FrameIndex {2}, TriggerCounter {3}, Overlays {4}, "  \
                 "Trigger: {5}\n{6} UTC".format(
                     det_id, run_id, frame_index, trigger_counter,
-                    overlays, trigger_params,
-                    datetime.utcfromtimestamp(utc_timestamp))
+                    overlays, trigger_params, dt)
 
         filename = 'ztplot'
         f = os.path.join(self.plots_path, filename + '.png')
-- 
GitLab