diff options
Diffstat (limited to 'pastepy.py')
-rw-r--r-- | pastepy.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -120,8 +120,12 @@ class Paste(object): try: cache = session.query(db.Cache).filter_by(paste_hash = hash).one() paste = cache.paste - except: # No cache found, generate it. - paste = session.query(db.Paste).filter_by(hash = hash).one() + except db.NoResultFound: # No cache found, generate it. + try: + paste = session.query(db.Paste).filter_by(hash = hash).one() + except db.NoResultFound: + self.start_response('404 Not Found', []) + return [] try: lexername, text = get_formatted(paste.syntax, paste.text if type(paste.text) == unicode else paste.text.decode('utf8')) except: |