Commit ebd69792 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

pithos: Change error handling in views

The view_method decorator used to check the response status:
in case of unexpected response used to return
Internal Server Error (500).
This commit changes this behavior and
the view_method decorator returns whatever the api_method decorator
(whose execution preceeds) returns.
parent 3c383100
......@@ -1134,15 +1134,11 @@ def view_method():
request.META['HTTP_X_AUTH_TOKEN'] = token
# Get the response object
response = func(request, *args, **kwargs)
if response.status_code in [200, 206, 304, 412, 416]:
return response
elif response.status_code == 404:
if response.status_code == 404:
raise Http404()
elif response.status_code in [401, 403]:
return HttpResponseForbidden()
# unexpected response status
raise Exception(response.status_code)
return response
return wrapper
return decorator
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment