Skip to content

Commit 5606348

Browse files
committed
Catch MissingTableError instead of bare Exception
1 parent 036e0f2 commit 5606348

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/datajoint/lineage.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import logging
1414

15+
from .errors import MissingTableError
16+
1517
logger = logging.getLogger(__name__.split(".")[0])
1618

1719
LINEAGE_TABLE_NAME = "~lineage"
@@ -48,8 +50,8 @@ def get_lineage(connection, database, table_name, attribute_name):
4850
)
4951
row = result.fetchone()
5052
return row[0] if row else None
51-
except Exception:
52-
# Table doesn't exist yet
53+
except MissingTableError:
54+
# ~lineage table doesn't exist yet
5355
return None
5456

5557

@@ -69,8 +71,8 @@ def get_all_lineages(connection, database, table_name):
6971
args=(table_name,),
7072
)
7173
return {row[0]: row[1] for row in result}
72-
except Exception:
73-
# Table doesn't exist yet
74+
except MissingTableError:
75+
# ~lineage table doesn't exist yet
7476
return {}
7577

7678

@@ -84,8 +86,8 @@ def delete_lineage_entries(connection, database, table_name):
8486
""",
8587
args=(table_name,),
8688
)
87-
except Exception:
88-
# Table doesn't exist yet - nothing to delete
89+
except MissingTableError:
90+
# ~lineage table doesn't exist yet - nothing to delete
8991
pass
9092

9193

0 commit comments

Comments
 (0)