Skip to content

Commit 2d2bc47

Browse files
committed
Log errors upon failure to connect to ISPyB, but attempt to boot up Murfey as far as is possible
1 parent 59297f9 commit 2d2bc47

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/murfey/server/ispyb.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
)
4545
)
4646
log.info("Loaded ISPyB database session")
47-
except AttributeError:
47+
# Catch all errors associated with loading ISPyB database
48+
except Exception:
4849
log.error("Error loading ISPyB session", exc_info=True)
4950
ISPyBSession = lambda: None
5051

@@ -66,13 +67,17 @@ def __init__(self, transport_type: Literal["PikaTransport"]):
6667
self.transport = workflows.transport.lookup(transport_type)()
6768
self.transport.connect()
6869
self.feedback_queue = ""
69-
self.ispyb = (
70-
ispyb.open(credentials=security_config.ispyb_credentials)
71-
if security_config.ispyb_credentials
72-
else None
73-
)
74-
if self.ispyb is not None:
75-
print("Loaded ISPyB databse")
70+
try:
71+
# Attempt to connect to ISPyB if credentials files provided
72+
self.ispyb = (
73+
ispyb.open(credentials=security_config.ispyb_credentials)
74+
if security_config.ispyb_credentials
75+
else None
76+
)
77+
except Exception:
78+
# Log error and return None if the connection fails
79+
log.error("Error encountered connecting to ISPyB server", exc_info=True)
80+
self.ispyb = None
7681
self._connection_callback: Callable | None = None
7782

7883
def reconnect(self):

0 commit comments

Comments
 (0)