Revision aad21b81
b/snf-django-lib/snf_django/lib/api/__init__.py | ||
---|---|---|
30 | 30 |
# documentation are those of the authors and should not be |
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 |
|
|
33 |
import sys |
|
34 | 34 |
from functools import wraps |
35 | 35 |
from traceback import format_exc |
36 | 36 |
from time import time |
... | ... | |
119 | 119 |
# Fill in response variables |
120 | 120 |
update_response_headers(request, response) |
121 | 121 |
return response |
122 |
except faults.Fault, fault:
|
|
122 |
except faults.Fault as fault:
|
|
123 | 123 |
if fault.code >= 500: |
124 |
logger.exception("API ERROR") |
|
124 |
logger.error("Unexpected API Error: %s", request.path, |
|
125 |
exc_info=sys.exc_info(), |
|
126 |
extra={ |
|
127 |
"status_code": fault.code, |
|
128 |
"request": request}) |
|
125 | 129 |
return render_fault(request, fault) |
126 | 130 |
except AstakosClientException as err: |
127 | 131 |
fault = faults.Fault(message=err.message, |
128 | 132 |
details=err.details, |
129 | 133 |
code=err.status) |
130 | 134 |
if fault.code >= 500: |
131 |
logger.exception("Astakos ERROR") |
|
135 |
logger.error("Unexpected AstakosClient Error: %s", |
|
136 |
request.path, |
|
137 |
exc_info=sys.exc_info(), |
|
138 |
extra={ |
|
139 |
"status_code": fault.code, |
|
140 |
"request": request}) |
|
132 | 141 |
return render_fault(request, fault) |
133 | 142 |
except: |
134 |
logger.exception("Unexpected ERROR") |
|
143 |
logger.error("Internal Server Error: %s", request.path, |
|
144 |
exc_info=sys.exc_info(), |
|
145 |
extra={ |
|
146 |
"status_code": '500', |
|
147 |
"request": request}) |
|
135 | 148 |
fault = faults.InternalServerError("Unexpected error") |
136 | 149 |
return render_fault(request, fault) |
137 | 150 |
return csrf.csrf_exempt(wrapper) |
Also available in: Unified diff