From f74f062b340157b17d99dbe47c61f65724894667 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 29 Apr 2021 19:40:15 +0200 Subject: [PATCH] add more exceptions to catch --- igniter/tools.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/igniter/tools.py b/igniter/tools.py index 5ebd34d891..529d535c25 100644 --- a/igniter/tools.py +++ b/igniter/tools.py @@ -17,7 +17,8 @@ from pymongo import MongoClient from pymongo.errors import ( ServerSelectionTimeoutError, InvalidURI, - ConfigurationError + ConfigurationError, + OperationFailure ) @@ -131,9 +132,7 @@ def validate_mongo_connection(cnx: str) -> (bool, str): return False, f"Cannot connect to server {cnx} - {e}" except ValueError: return False, f"Invalid port specified {parsed.port}" - except InvalidURI as e: - return False, str(e) - except ConfigurationError as exc: + except (ConfigurationError, OperationFailure, InvalidURI) as exc: return False, str(exc) else: return True, "Connection is successful"