From f384165ba97909ba357dcd2dec515dbbef6691bf Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Fri, 17 Dec 2021 16:01:11 +0100
Subject: [PATCH] L2SS-544: Be more specific when matching exceptions

---
 tangostationcontrol/tangostationcontrol/toolkit/archiver.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/toolkit/archiver.py b/tangostationcontrol/tangostationcontrol/toolkit/archiver.py
index 35b718f81..7a62c18fd 100644
--- a/tangostationcontrol/tangostationcontrol/toolkit/archiver.py
+++ b/tangostationcontrol/tangostationcontrol/toolkit/archiver.py
@@ -186,11 +186,11 @@ class Archiver():
             if es.state() == DevState.FAULT:
                 raise Exception(f"Event Subscriber {es_name} is in FAULT state")
             self.cm.ArchiverAdd(device_name_url(es_name))
-        except Exception as e:
-            if 'already_present' in str(e):
+        except DevFailed as e:
+            if e.args[0].reason == "Archiver already present":
                 logger.warning(f"Event Subscriber {es_name} already present in Configuration Manager")
             else:
-                raise Exception from e
+                raise
 
     def add_attribute_to_archiver(self, attribute_name: str, polling_period: int, event_period: int, strategy: str = 'RUN', es_name:str=None):
         """
-- 
GitLab