From d33cdbcf62802202e662cea1c9a2dc691da6f7b4 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 6 Nov 2023 13:51:32 -0900 Subject: [PATCH] error handling for invalid dataset passed to datasets keyword --- asf_search/CMR/translate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/asf_search/CMR/translate.py b/asf_search/CMR/translate.py index 1eb91e51..703bbfda 100644 --- a/asf_search/CMR/translate.py +++ b/asf_search/CMR/translate.py @@ -52,8 +52,11 @@ def translate_opts(opts: ASFSearchOptions) -> list: if 'collections' not in dict_opts: dict_opts['collections'] = [] - for collection in dict_opts['datasets']: - dict_opts['collections'].extend(platform_datasets[collection]) + for dataset in dict_opts['datasets']: + if dataset_collections := platform_datasets.get(dataset): + dict_opts['collections'].extend(dataset_collections) + else: + raise ValueError(f'Could not find dataset named "{dataset}" provided for datasets keyword.') dict_opts.pop('datasets')