orf / simple

Simple is a clone of Obtvse written in Python running on Flask.
MIT License
505 stars 280 forks source link

change 404 error handling when post is not found. #42

Closed grnxp closed 11 years ago

grnxp commented 11 years ago

Hi again,

Just a small proposition for your "better exception" comment: I changed the type of caught exceptions to sqlalchemy.orm.exc.NoResultFoundException. With this, if .one() function fails because no result was found, the exception is raised and abort(404) is executed. If another exception is raised, it should be intercepted by Flask, which will then display the 500 error page.

Note that it's not mandatory to "return" before the abort() function, as mentioned here http://flask.pocoo.org/docs/quickstart/#redirects-and-errors .

Do you see anything else to improve this a little bit more?

Thanks !

orf commented 11 years ago

Thanks!