bebatut / enasearch

A Python library for interacting with ENA's API
http://bebatut.fr/enasearch
MIT License
22 stars 6 forks source link

Friendly handling of illegal --fields #13

Closed tseemann closed 7 years ago

tseemann commented 7 years ago

Is it possible to handle non-existent field names in a nicer way? The python backtrace is ugly.

% retrieve_run_report --accession PRJNA275974 --fields run_accession --fields wrong_name

Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/bin/enasearch", line 11, in <module>
    load_entry_point('enasearch==0.0.6', 'console_scripts', 'enasearch')()
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/enasearch/__main__.py", line 353, in retrieve_run_report
    file=file)
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/enasearch/__init__.py", line 653, in retrieve_run_report
    file=file)
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/enasearch/__init__.py", line 633, in retrieve_filereport
    check_returnable_fields(fields.split(","), result)
  File "/home/linuxbrew/.linuxbrew/opt/python3/lib/python3.6/site-packages/enasearch/__init__.py", line 136, in check_returnable_fields
    raise ValueError(err_str)
ValueError: The field wrong_name is not a returnable field for result read_run
bebatut commented 7 years ago

Should be fixed with #16