ezodf icon indicating copy to clipboard operation
ezodf copied to clipboard

Useless error message if wrong file path is given

Open ghost opened this issue 8 years ago • 1 comments

If one calls opendoc() with a non-existing path:

opened = ezodf.opendoc("/home/user/path/that/does/not/exist.ods")

This is what one gets:

Traceback (most recent call last):
  File "/home/yyyyyyy/loop_list_test.py", line 9, in <module>
    adapted_ods = ezodf.opendoc(adapted)
  File "/usr/local/lib/python2.7/dist-packages/ezodf/document.py", line 54, in opendoc
    mime_type = __detect_mime_type(fm)
  File "/usr/local/lib/python2.7/dist-packages/ezodf/document.py", line 69, in __detect_mime_type
    mime_type = MIMETYPES[ext]
KeyError: '.ods'

It's just a suggestion but a simple check if that file actually exists and a more meaningful error message would be very helpful here.

ghost avatar Aug 04 '16 09:08 ghost

Got bitten by this error. I had restructured some directories and didn't notice the path wasn't right. Thanks for filing this bug!

franciscod avatar Jan 27 '17 05:01 franciscod