From dfa5805a367327acad8fdb6b6710eec7777517a4 Mon Sep 17 00:00:00 2001 From: Andrew Olsen Date: Tue, 8 Sep 2020 10:49:22 +1200 Subject: [PATCH] Better error message for half-initialised working copy. --- sno/working_copy.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sno/working_copy.py b/sno/working_copy.py index 8e561d6ee..2e383dfb4 100644 --- a/sno/working_copy.py +++ b/sno/working_copy.py @@ -12,7 +12,7 @@ from . import gpkg, gpkg_adapter from .diff_structs import RepoDiff, DatasetDiff, DeltaDiff, Delta -from .exceptions import InvalidOperation, NotYetImplemented +from .exceptions import InvalidOperation, NotYetImplemented, NotFound, NO_WORKING_COPY from .filter_util import UNFILTERED from .geometry import Geometry, normalise_gpkg_geom from .schema import Schema @@ -554,7 +554,12 @@ def get_db_tree(self, table_name="*"): ) row = dbcur.fetchone() if not row: - raise ValueError(f"No tree entry in state_table for {table_name}") + L.debug(f"No tree entry in state_table for {table_name}") + # This happens if you start trying to use the working copy when it is half written. + raise NotFound( + f"Working copy at {self.path} is not fully initialised", + NO_WORKING_COPY, + ) wc_tree_id = row[0] return wc_tree_id