Repository: opendatacube/datacube-core

Issue:
ambiguous error message for adding product
### Expected behaviour
When indexing a dataset with missing lineage, the error message clearly states the required `lineage` product does not exist.

### Actual behaviour

```
ows@7e921b6b2d35:/code$ datacube dataset add https://data.dea.ga.gov.au/derivative/ga_ls_fc_3/2-5-1/094/077/2018/02/08/ga_ls_fc_3_094077_2018-02-08_final.odc-metadata.yaml
Indexing datasets  [------------------------------------]    0%2022-05-11 04:05:29,918 205 datacube-dataset ERROR No matching Product found for dataset 58c13585-520a-44f0-8a58-6c69bb5b3809
Indexing datasets  [####################################]  100%
```

the reported dataset is 

```
jovyan@jupyter-pin-2ejin-40ga-2egov-2eau:~$ datacube dataset search id= 58c13585-520a-44f0-8a58-6c69bb5b3809
id: 58c13585-520a-44f0-8a58-6c69bb5b3809
product: ga_ls8c_ard_3
status: active
locations:
- s3://dea-public-data/baseline/ga_ls8c_ard_3/094/077/2018/02/08/ga_ls8c_ard_3-0-0_094077_2018-02-08_final.stac-item.json
fields:
    cloud_cover: 0.03532670025988712
    creation_time: 2019-10-05 23:34:08.757833+00:00
    crs_raw: epsg:32655
    dataset_maturity: final
    eo_gsd: 15.0
    eo_sun_azimuth: 80.04092155
    eo_sun_elevation: 56.55465709
    fmask_clear: 99.9137820594157
    fmask_cloud_shadow: 0.033708458854312055
    fmask_snow: 0.0
    fmask_water: 0.017182781470106115
    format: GeoTIFF
    gqa: 0.23
    gqa_abs_iterative_mean_x: 0.09
    gqa_abs_iterative_mean_xy: 0.13
    gqa_abs_iterative_mean_y: 0.09
    gqa_abs_x: 0.13
    gqa_abs_xy: 0.2
    gqa_abs_y: 0.15
    gqa_cep90: 0.23
    gqa_iterative_mean_x: -0.09
    gqa_iterative_mean_xy: 0.12
    gqa_iterative_mean_y: 0.08
    gqa_iterative_stddev_x: 0.07
    gqa_iterative_stddev_xy: 0.1
    gqa_iterative_stddev_y: 0.07
    gqa_mean_x: -0.09
    gqa_mean_xy: 0.12
    gqa_mean_y: 0.08
    gqa_stddev_x: 0.15
    gqa_stddev_xy: 0.23
    gqa_stddev_y: 0.17
    instrument: OLI_TIRS
    label: ga_ls8c_ard_3-0-0_094077_2018-02-08_final
    landsat_product_id: LC08_L1TP_094077_20180208_20180221_01_T1
    landsat_scene_id: LC80940772018039LGN00
    lat: {begin: -25.604850386218608, end: -23.503301591340538}
    lon: {begin: 145.16596446610487, end: 147.43481699240712}
    platform: landsat-8
    product_family: ard
    region_code: 094077
    time: {begin: '2018-02-08T00:11:49.246333+00:00', end: '2018-02-08T00:12:19.267390+00:00'}
```


### Steps to reproduce the behaviour

with an empty database

```
datacube system init
datacube metadata add https://raw.githubusercontent.com/GeoscienceAustralia/dea-config/master/product_metadata/eo3_landsat_ard.odc-type.yaml
datacube product add https://raw.githubusercontent.com/GeoscienceAustralia/dea-config/master/products/baseline_satellite_data/c3/ga_ls8c_ard_3.odc-product.yaml
datacube product add https://raw.githubusercontent.com/GeoscienceAustralia/dea-config/master/products/land_and_vegetation/c3_fc/ga_ls_fc_3.odc-product.yaml
datacube dataset add https://data.dea.ga.gov.au/derivative/ga_ls_fc_3/2-5-1/094/077/2018/02/08/ga_ls_fc_3_094077_2018-02-08_final.odc-metadata.yaml
```

### Environment information

* Which ``datacube --version`` are you using?
* What datacube deployment/enviornment are you running against?


> **Note:** Stale issues will be automatically closed after a period of six months with no activity. 
> To ensure critical issues are not closed, tag them with the Github `pinned` tag.
> If you are a community member and not a maintainer please escalate this issue to maintainers via
> [GIS StackExchange](https://gis.stackexchange.com/questions/tagged/open-data-cube) or [Slack](http://slack.opendatacube.org).



Discussion:

Resolving patch:
diff --git a/datacube/index/hl.py b/datacube/index/hl.py
--- a/datacube/index/hl.py
+++ b/datacube/index/hl.py
@@ -11,15 +11,11 @@
 
 from datacube.model import Dataset
 from datacube.utils import changes, InvalidDocException, SimpleDocNav, jsonify_document
-from datacube.model.utils import dedup_lineage, remap_lineage_doc, flatten_datasets
+from datacube.model.utils import BadMatch, dedup_lineage, remap_lineage_doc, flatten_datasets
 from datacube.utils.changes import get_doc_changes
 from .eo3 import prep_eo3, is_doc_eo3
 
 
-class BadMatch(Exception):
-    pass
-
-
 def load_rules_from_types(index, product_names=None, excluding=None):
     products = []
     if product_names:
diff --git a/datacube/model/utils.py b/datacube/model/utils.py
--- a/datacube/model/utils.py
+++ b/datacube/model/utils.py
@@ -25,6 +25,10 @@
     from yaml import SafeDumper  # type: ignore
 
 
+class BadMatch(Exception):
+    pass
+
+
 def machine_info():
     info = {
         'software_versions': {
@@ -346,7 +350,13 @@ def visit(ds):
     if not isinstance(root, SimpleDocNav):
         root = SimpleDocNav(root)
 
-    return visit(root)
+    try:
+        return visit(root)
+    except BadMatch as e:
+        if root.id not in str(e):
+            raise BadMatch(f"Error loading lineage dataset: {e}") from None
+        else:
+            raise
 
 
 def dedup_lineage(root):


Test patch:
diff --git a/integration_tests/test_dataset_add.py b/integration_tests/test_dataset_add.py
--- a/integration_tests/test_dataset_add.py
+++ b/integration_tests/test_dataset_add.py
@@ -41,13 +41,15 @@ def check_no_product_match(clirunner, index):
     r = clirunner(['dataset', 'add',
                    '--product', 'A',
                    str(prefix)])
-    assert 'ERROR Dataset metadata did not match product signature' in r.output
+    assert 'ERROR' in r.output
+    assert 'Dataset metadata did not match product signature' in r.output
 
     r = clirunner(['dataset', 'add',
                    '--product', 'A',
                    '--product', 'B',
                    str(prefix)])
-    assert 'ERROR No matching Product found for dataset' in r.output
+    assert 'ERROR' in r.output
+    assert 'No matching Product found for dataset' in r.output
 
     ds_ = index.datasets.get(ds.id, include_sources=True)
     assert ds_ is None
@@ -58,7 +60,8 @@ def check_no_product_match(clirunner, index):
                    '--confirm-ignore-lineage',
                    str(prefix)])
 
-    assert 'ERROR Dataset metadata did not match product signature' in r.output
+    assert 'ERROR' in r.output
+    assert 'Dataset metadata did not match product signature' in r.output
     assert index.datasets.has(ds.id) is False