Commit abf7848e authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis Committed by Christos Stavrakakis
Browse files

Handle AstakosClientException in api_method decorator

parent df9c68bb
......@@ -90,15 +90,10 @@ def api_method(http_method=None, token_required=True, user_required=True,
if user_required:
assert(token_required), "Can not get user without token"
astakos = astakos_url or settings.ASTAKOS_URL
try:
astakos = AstakosClient(astakos,
use_pool=True,
logger=logger)
user_info = astakos.get_user_info(token)
except AstakosClientException as err:
raise faults.Fault(message=err.message,
details=err.details,
code=err.status)
astakos = AstakosClient(astakos,
use_pool=True,
logger=logger)
user_info = astakos.get_user_info(token)
request.user_uniq = user_info["uuid"]
request.user = user_info
......@@ -112,6 +107,13 @@ def api_method(http_method=None, token_required=True, user_required=True,
if fault.code >= 500:
logger.exception("API ERROR")
return render_fault(request, fault)
except AstakosClientException as err:
fault = faults.Fault(message=err.message,
details=err.details,
code=err.status)
if fault.code >= 500:
logger.exception("API ERROR")
return render_fault(request, fault)
except:
logger.exception("Unexpected ERROR")
fault = faults.InternalServerError("Unexpected ERROR")
......
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