From 9437f81558e5ddec1d87d88e22307b5e7e1a0a2f Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Fri, 17 Dec 2021 15:44:15 +0100 Subject: [PATCH] L2SS-544: Be more specific when matching exceptions --- .../tangostationcontrol/toolkit/archiver.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tangostationcontrol/tangostationcontrol/toolkit/archiver.py b/tangostationcontrol/tangostationcontrol/toolkit/archiver.py index d822d729c..35b718f81 100644 --- a/tangostationcontrol/tangostationcontrol/toolkit/archiver.py +++ b/tangostationcontrol/tangostationcontrol/toolkit/archiver.py @@ -208,11 +208,11 @@ class Archiver(): self.cm.write_attribute('SetPeriodEvent', event_period) self.cm.AttributeAdd() logger.info(f"Attribute {attribute_name} added to archiving list!") - except Exception as e: - if 'already archived' not in str(e).lower(): - raise Exception from e - else: + except DevFailed as e: + if e.args[0].reason == 'Already archived': logger.warning(f"Attribute {attribute_name} already in archiving list!") + else: + raise def add_attributes_by_device(self,device_name,global_archive_period:int = None, es_name:str=None, exclude:list = []): """ -- GitLab