diff --git a/cate/core/ds.py b/cate/core/ds.py
index 55070fcec..62274c4ef 100644
--- a/cate/core/ds.py
+++ b/cate/core/ds.py
@@ -463,18 +463,30 @@ class DataAccessError(Exception):
Exceptions produced by Cate's data stores and data sources instances, used to report any problems handling data.
"""
def __init__(self, source, cause, *args, **kwargs):
- if isinstance(source, DataSource) or isinstance(source, DataStore):
+ self._source = source
+ if isinstance(source, DataSource):
+ source_name = 'DataSource'
+ elif isinstance(source, DataStore):
+ source_name = 'DataStore'
+ else:
+ source_name = ""
+
+ if source_name:
if isinstance(cause, Exception):
- super(DataAccessError, self).__init__("{}({}): {}".format(source.__class__, source.id, str(cause)),
- *args, **kwargs)
+ super(DataAccessError, self).__init__("{} '{}' returned error: {}".format(source_name, source.id,
+ str(cause)), *args, **kwargs)
elif isinstance(cause, str):
- super(DataAccessError, self).__init__("{}({}): {}".format(source.__class__, source.id, cause),
- *args, **kwargs)
+ super(DataAccessError, self).__init__("{} '{}' returned error: {}".format(source_name, source.id,
+ cause), *args, **kwargs)
+ else:
+ super(DataAccessError, self).__init__(*args, **kwargs)
else:
if isinstance(cause, Exception):
super(DataAccessError, self).__init__(str(cause), *args, **kwargs)
- else:
+ elif isinstance(cause, str):
super(DataAccessError, self).__init__(cause, *args, **kwargs)
+ else:
+ super(DataAccessError, self).__init__(*args, **kwargs)
@property
def cause(self):
diff --git a/cate/ds/esa_cci_odp.py b/cate/ds/esa_cci_odp.py
index 5bab8ee26..ae3301755 100644
--- a/cate/ds/esa_cci_odp.py
+++ b/cate/ds/esa_cci_odp.py
@@ -349,7 +349,7 @@ def _repr_html_(self) -> str:
return '
Contents of FileSetFileStore
' % ('\n'.join(rows))
def __repr__(self) -> str:
- return "EsaCciOdpDataStore"
+ return "EsaCciOdpDataStore (%s)" % self.id
def _init_data_sources(self):
if self._data_sources:
diff --git a/test/ds/test_esa_cci_odp.py b/test/ds/test_esa_cci_odp.py
index e9477e295..3c08f35a6 100644
--- a/test/ds/test_esa_cci_odp.py
+++ b/test/ds/test_esa_cci_odp.py
@@ -8,7 +8,7 @@
import urllib.request
import shutil
-from cate.core.ds import DATA_STORE_REGISTRY, format_variables_info_string
+from cate.core.ds import DATA_STORE_REGISTRY, DataAccessError, format_variables_info_string
from cate.core.types import PolygonLike, TimeRangeLike, VarNamesLike
from cate.ds.esa_cci_odp import EsaCciOdpDataStore, find_datetime_format
from cate.ds.local import LocalDataStore
@@ -203,10 +203,13 @@ def build_file_item(item_name: str, date_from: datetime, date_to: datetime, size
self.assertSetEqual(set(data_set.variables), set(new_ds_w_region_var_names))
- no_data = soilmoisture_data_source.make_local('empty_ds',
- time_range=(datetime.datetime(2017, 12, 1, 0, 0),
- datetime.datetime(2017, 12, 31, 23, 59)))
- self.assertIsNone(no_data)
+ empty_ds_timerange = (datetime.datetime(2017, 12, 1, 0, 0), datetime.datetime(2017, 12, 31, 23, 59))
+ with self.assertRaises(DataAccessError) as cm:
+ soilmoisture_data_source.make_local('empty_ds', time_range=empty_ds_timerange)
+ self.assertEqual("Open Data Portal's data source '{}' does not seem to have any data sets in given "
+ "time range {}".format(soilmoisture_data_source.id,
+ TimeRangeLike.format(empty_ds_timerange)),
+ str(cm.exception))
new_ds_time_range = TimeRangeLike.convert((datetime.datetime(1978, 11, 14, 0, 0),
datetime.datetime(1978, 11, 14, 23, 59)))
diff --git a/test/ds/test_local.py b/test/ds/test_local.py
index 100a060c0..b540c36b4 100644
--- a/test/ds/test_local.py
+++ b/test/ds/test_local.py
@@ -49,8 +49,8 @@ def test_add_pattern(self):
with self.assertRaises(DataAccessError) as cm:
self.data_store.add_pattern("a_name", "a_pat2")
- self.assertEqual("{}: Data source '{}.{}' already exists.".format(
- self.data_store, self.data_store.id, new_ds_name), str(cm.exception))
+ self.assertEqual("DataStore '{}' returned error: Data source '{}.{}' already exists.".format(
+ self.data_store.id, self.data_store.id, new_ds_name), str(cm.exception))
data_sources = self.data_store.query()
self.assertEqual(len(data_sources), 3)