pmlrsg/GISportal

Error handling code when user is not logged in

doclements opened this issue · 1 comments

Code creates a silent HTTP 500 error and creates the below stacktrace.

[Thu Apr 03 14:24:16.644533 2014] [:error] [pid 7025] [remote 192.171.164.51:180] Traceback (most recent call last):
[Thu Apr 03 14:24:16.644568 2014] [:error] [pid 7025] [remote 192.171.164.51:180]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
[Thu Apr 03 14:24:16.645191 2014] [:error] [pid 7025] [remote 192.171.164.51:180]     return self.wsgi_app(environ, start_response)
[Thu Apr 03 14:24:16.645219 2014] [:error] [pid 7025] [remote 192.171.164.51:180]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
[Thu Apr 03 14:24:16.645250 2014] [:error] [pid 7025] [remote 192.171.164.51:180]     response = self.make_response(self.handle_exception(e))
[Thu Apr 03 14:24:16.645268 2014] [:error] [pid 7025] [remote 192.171.164.51:180]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
[Thu Apr 03 14:24:16.645292 2014] [:error] [pid 7025] [remote 192.171.164.51:180]     response = self.full_dispatch_request()
[Thu Apr 03 14:24:16.645309 2014] [:error] [pid 7025] [remote 192.171.164.51:180]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
[Thu Apr 03 14:24:16.645332 2014] [:error] [pid 7025] [remote 192.171.164.51:180]     rv = self.handle_user_exception(e)
[Thu Apr 03 14:24:16.645348 2014] [:error] [pid 7025] [remote 192.171.164.51:180]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
[Thu Apr 03 14:24:16.645371 2014] [:error] [pid 7025] [remote 192.171.164.51:180]     rv = self.dispatch_request()
[Thu Apr 03 14:24:16.645387 2014] [:error] [pid 7025] [remote 192.171.164.51:180]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
[Thu Apr 03 14:24:16.645410 2014] [:error] [pid 7025] [remote 192.171.164.51:180]     return self.view_functions[rule.endpoint](**req.view_args)
[Thu Apr 03 14:24:16.645427 2014] [:error] [pid 7025] [remote 192.171.164.51:180]   File "/home/rsgadmin/oceancolour.org/OpEcVis/middleware/portalflask/views/graph.py", line 93, in setGraph
[Thu Apr 03 14:24:16.645590 2014] [:error] [pid 7025] [remote 192.171.164.51:180]     error_handler.setError('2-01', state, g.user.id, "views/graphs.py:setGraph - The user is no t logged in, returning 401 to user.", request)
[Thu Apr 03 14:24:16.645642 2014] [:error] [pid 7025] [remote 192.171.164.51:180] NameError: global name 'error_handler' is not defined

The error handler class was not imported and it was also looking for g.user.id when g.user did not exist. Fixed.