please use specific exception types in the documentation
Issue #1365
resolved
The tutorial at http://www.sqlalchemy.org/docs/05/ormtutorial.html#returning-lists-and-scalars has an example
>>> try:
... user = query.one()
... except Exception, e:
... print e
It is generally considered bad style to catch generic exceptions. I would therefore suggest that the example be amended to catch the specific exception that SQLAlchemy raises in one():
>>> from sqlalchemy.orm.exc import MultipleResultsFound
>>> try:
... user = query.one()
... except MultipleResultsFound, e:
... print e
and, in a similar way, the next example
>>> from sqlalchemy.orm.exc import NoResultFound
>>> try:
... user = query.filter(User.id == 99).one()
... except NoResultFound, e:
... print e
Comments (2)
-
-
repo owner - removed milestone
Removing milestone: 0.5.4 (automated comment)
- Log in to comment
Thanks for the cleanup. Fixed in 7f1e6621f8d856d9487e93df9baf2ada49bc4cae.