def wrapper(*args, **kwargs): try: return route_func(*args, **kwargs) except (IncorrectParameterException, ValueError) as e: # ValueError for bad UUID. logger.warning(str(e)) return form_response(400, False, description=dict(error=str(e))) except ClosedBankAccountExeption as e: logger.info(str(e)) return form_response(403, False, description=dict(error=str(e))) except UUIDNotFoundException as e: logger.info(str(e)) return form_response(404, False, description=dict(error=str(e))) except NotEnoughMoney as e: logger.info(str(e)) return form_response(406, False, description=dict(error=str(e))) except Exception as e: logger.error(str(e)) return form_response(500, False, description=dict(error=str(e)))
def status(): logger.debug('Status was called.') json_data = JSONData(request.data) balance, status = get_status(json_data.uuid) return form_response(200, True, json_data.uuid, addition=dict(balance=balance, status=status))
def subtract(): logger.debug('Subtract was called.') json_data = JSONData(request.data) subtract_sum(json_data.uuid, json_data.value) return form_response(200, True, json_data.uuid)
def add(): logger.debug('Add was called.') json_data = JSONData(request.data) add_sum(json_data.uuid, json_data.value) return form_response(200, True, json_data.uuid)
def ping(): logger.debug('Ping was called.') return form_response(200, True)