cernopendata / cernopendata-client

CERN Open Data command-line client
http://cernopendata-client.readthedocs.io/
GNU General Public License v3.0
10 stars 9 forks source link

Raise exceptions when using the methods outside the CLI #124

Open avivace opened 3 years ago

avivace commented 3 years ago

When using cernopendata-client as a module and importing the searcher (or downloader) method, any error will cause the entire execution flow to break. This should happen when using the cernopendata-client CLI, but elsewhere those methods should raise an Exception that the importing application can handle and carry on.

E.g., When you look for a non-existing record id:

from cernopendata_client import searcher, downloader
metadata = searcher.get_record_as_json(server=self.SERVER_HTTP_URI, recid=recid)

The script exists immediatly (without raising any Exception) and interrupting any calling action:

==> ERROR: The record id number you supplied is not valid.