Skip to content

Commit 189352c

Browse files
committed
Hard abort on DB errors
1 parent 79027c3 commit 189352c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fixattiosync/fixdata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import psycopg
34
from psycopg.rows import dict_row
45
from uuid import UUID
@@ -42,7 +43,7 @@ def connect(self) -> None:
4243
log.debug("Connection successful")
4344
except psycopg.DatabaseError as e:
4445
log.error(f"Error connecting to the database: {e}")
45-
self.conn = None
46+
sys.exit(2)
4647

4748
def hydrate(self) -> None:
4849
if self.conn is None:
@@ -76,7 +77,7 @@ def hydrate(self) -> None:
7677
self.__users[row["user_id"]].workspaces.append(self.__workspaces[row["organization_id"]])
7778
except psycopg.Error as e:
7879
log.error(f"Error fetching data: {e}")
79-
return None
80+
sys.exit(2)
8081
finally:
8182
self.close()
8283
log.debug(f"Found {len(self.__workspaces)} workspaces in database")

0 commit comments

Comments
 (0)