When an element is not found, a confusing sqlalchemy error is raised.
To Reproduce
Steps to reproduce the behavior:
>>> import mendeleev
>>> mendeleev.element("si")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/g/.local/lib/python3.10/site-packages/mendeleev/mendeleev.py", line 64, in element
return _get_element(ids)
File "/home/g/.local/lib/python3.10/site-packages/mendeleev/mendeleev.py", line 81, in _get_element
return session.query(Element).filter(Element.symbol == str(ids)).one()
File "/home/g/.local/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 2797, in one
return self._iter().one() # type: ignore
File "/home/g/.local/lib/python3.10/site-packages/sqlalchemy/engine/result.py", line 1827, in one
return self._only_one_row(
File "/home/g/.local/lib/python3.10/site-packages/sqlalchemy/engine/result.py", line 760, in _only_one_row
raise exc.NoResultFound(
sqlalchemy.exc.NoResultFound: No row was found when one was require
Expected behavior
A clear error message saying that the element was not found, without showing sqlalchemy, which is an implementation detail.
Thanks for reporting this @Vi-L . Indeed the error message can be quite confusing. It comes straight from SQLAlchemy but that's not a detail that needs to be exposed to end users.
Describe the bug
When an element is not found, a confusing sqlalchemy error is raised.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear error message saying that the element was not found, without showing sqlalchemy, which is an implementation detail.
Specification
Additional context
See this post.