From b3eff6ab32b2a75e7b074f4e2c26bc65f87335fd Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sun, 27 Nov 2022 13:02:54 +0000 Subject: [PATCH] monitor: Catch any failure to coerce `gameversion` Also, log either the error or the success. That will aid us in diagnosing any future issues. --- monitor.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index f2a68b95..52a53c51 100644 --- a/monitor.py +++ b/monitor.py @@ -1686,7 +1686,20 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['GameVersion'] = entry['gameversion'] self.state['GameBuild'] = entry['build'] self.version = self.state['GameVersion'] - self.version_semantic = semantic_version.Version.coerce(self.state['GameVersion']) + + try: + self.version_semantic = semantic_version.Version.coerce(self.state['GameVersion']) + + except Exception: + # Catching all Exceptions as this is *one* call, and we won't + # get caught out by any semantic_version changes. + self.version_semantic = None + logger.error(f"Couldn't coerce {self.state['GameVersion']=}") + pass + + else: + logger.info(f"Parsed {self.state['GameVersion']=} into {self.version_semantic=}") + self.is_beta = any(v in self.version.lower() for v in ('alpha', 'beta')) # type: ignore except KeyError: if not suppress: