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 needed columns are missing #5

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 is missing then one gets a cryptic error message at the moment: windows_img_path, id_box, x, y, width & height.

Example of a current not-user-friendly error message when the column windows_img_path is missing (e.g. renamed by accident, or simply missing):

Selection_144

---------------------------
Error
---------------------------
Traceback (most recent call last):
  File "c:\python38\lib\site-packages\pandas\core\indexes\base.py", line 2895, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas\_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'windows_img_path'

The above exception was the direct cause of the following exception:

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 44, in display_img
    img_path = df['windows_img_path'][0]
  File "c:\python38\lib\site-packages\pandas\core\frame.py", line 2902, in __getitem__
    indexer = self.columns.get_loc(key)
  File "c:\python38\lib\site-packages\pandas\core\indexes\base.py", line 2897, in get_loc
    raise KeyError(key) from err
KeyError: 'windows_img_path'

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