mattoufoutu/shorty — Issue #10: Error returned on wrong short_code
Author: Daroth
Created: 2012-02-04 11:10:24+00:00
State: open

When I generate a short url, let's say http://localhost:5000/867nv and then tries to redirect to it but with 1 char removed (eg http://localhost:5000/867n), I've a

AttributeError: 'NoneType' object has no attribute 'long_url' returned.

Here is the traceback stack :

Traceback (most recent call last):
File "/home/debaser/virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1518, in __call__
return self.wsgi_app(environ, start_response)
File "/home/debaser/virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1506, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/debaser/virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1504, in wsgi_app
response = self.full_dispatch_request()
File "/home/debaser/virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1264, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/debaser/virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1262, in full_dispatch_request
rv = self.dispatch_request()
File "/home/debaser/virtualenvs/flask/lib/python2.7/site-packages/flask/app.py", line 1248, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/debaser/virtualenvs/flask/lib/python2.7/site-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/home/debaser/projets/shorty/shorty/views/frontend.py", line 76, in dispatch_request
return redirect(url_obj.long_url)
AttributeError: 'NoneType' object has no attribute 'long_url'