diff --git a/polytope_feature/datacube/backends/fdb.py b/polytope_feature/datacube/backends/fdb.py index 2e8a877d7..bd60665af 100644 --- a/polytope_feature/datacube/backends/fdb.py +++ b/polytope_feature/datacube/backends/fdb.py @@ -3,7 +3,7 @@ from copy import deepcopy from itertools import product -from ...utility.exceptions import BadRequestError +from ...utility.exceptions import BadGridError, BadRequestError from ...utility.geometry import nearest_pt from .datacube import Datacube, TensorIndexTree @@ -128,7 +128,15 @@ def get(self, requests: TensorIndexTree, context=None): printed_list_to_gj = complete_list_complete_uncompressed_requests[::1000] logging.debug("The requests we give GribJump are: %s", printed_list_to_gj) logging.info("Requests given to GribJump extract for %s", context) - output_values = self.gj.extract(complete_list_complete_uncompressed_requests, context) + try: + output_values = self.gj.extract(complete_list_complete_uncompressed_requests, context) + except Exception as e: + if "BadValue: Grid hash mismatch" in str(e): + logging.info("Error is: %s", e) + raise BadGridError() + else: + raise e + logging.info("Requests extracted from GribJump for %s", context) if logging.root.level <= logging.DEBUG: printed_output_values = output_values[::1000] diff --git a/polytope_feature/utility/exceptions.py b/polytope_feature/utility/exceptions.py index 189bddf71..29cce5085 100644 --- a/polytope_feature/utility/exceptions.py +++ b/polytope_feature/utility/exceptions.py @@ -33,3 +33,8 @@ class UnsliceableShapeError(PolytopeError, KeyError): def __init__(self, axis): self.axis = axis self.message = f"Higher-dimensional shape does not support unsliceable axis {axis.name}." + + +class BadGridError(PolytopeError, ValueError): + def __init__(self): + self.message = "Data on this grid is not supported by Polytope."