Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement informative error messages if the values in needed columns are missing or are unexpected #6

Open
valentinitnelav opened this issue Oct 27, 2022 · 0 comments

Comments

@valentinitnelav
Copy link
Owner

valentinitnelav commented Oct 27, 2022

If any of these columns (windows_img_path, id_box, x, y, width & height) contain unexpected values, then one gets a cryptic error message at the moment.

Example of a current not-user-friendly error message when in the column windows_img_path one has a number instead of the expected absolute file path:

Selection_145

---------------------------
Error
---------------------------
Traceback (most recent call last):
  File "c:\python38\lib\site-packages\PIL\Image.py", line 3096, in open
    fp.seek(0)
AttributeError: 'numpy.float64' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\...\field-img-taxa-annotation\vba_python_img_with_box\xlwings_test\xlwings_test_project.py", line 68, in main
    display_img()
  File "C:\...\field-img-taxa-annotation\vba_python_img_with_box\xlwings_test\xlwings_test_project.py", line 46, in display_img
    with Image.open(img_path) as im:
  File "c:\python38\lib\site-packages\PIL\Image.py", line 3098, in open
    fp = io.BytesIO(fp.read())
AttributeError: 'numpy.float64' object has no attribute 'read'

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK   
---------------------------

When the absolute path has a typo, the error message is a bit more clear and can leave it as it is for now:

---------------------------
Error
---------------------------
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\...\field-img-taxa-annotation\vba_python_img_with_box\xlwings_test\xlwings_test_project.py", line 68, in main
    display_img()
  File "C:\...\field-img-taxa-annotation\vba_python_img_with_box\xlwings_test\xlwings_test_project.py", line 46, in display_img
    with Image.open(img_path) as im:
  File "c:\python38\lib\site-packages\PIL\Image.py", line 3092, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\...\\field-img\\2021-07-06\\Centaurea-scabiosa-01\\IMG_0377.JPG'

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK   
---------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant