diff --git a/src/cal_tools/tools.py b/src/cal_tools/tools.py
index 94d5e4a760bd6bc17862d8f05283cb0dd871f077..962f1a0db3dbd314d010f762a72cfb997e63f0b5 100644
--- a/src/cal_tools/tools.py
+++ b/src/cal_tools/tools.py
@@ -703,7 +703,12 @@ def send_to_db(db_module: str, karabo_id: str, constant, condition,
                     raise
             except Exception as e:
                 # TODO: refactor to use custom exception class
-                if "has already been taken" in str(e):
+                # Refactor error message for re-injecting an
+                # identical CCV to the database.
+                if all(s in str(e) for s in [
+                    "Error creating calibration_constant_version",
+                    "has already been taken",
+                ]):
                     print(
                         f"WARNING: {constant.name} for {db_module}"
                         " has already been injected with the same "