Small api logic changes, small order changes
This commit is contained in:
@@ -44,26 +44,28 @@ API_ERROR_VALIDATION = {
|
||||
|
||||
|
||||
def make_error_object(ex: Exception):
|
||||
data = {
|
||||
"status": "error"
|
||||
}
|
||||
try:
|
||||
if type(ex.args[0]) != tuple:
|
||||
raise Exception(API_ERROR_INTERNAL_ERROR)
|
||||
raise ex
|
||||
|
||||
data = {
|
||||
"error": {
|
||||
"code": ex.args[0][0],
|
||||
"message": ex.args[0][1]
|
||||
}
|
||||
data["error"] = {
|
||||
"code": ex.args[0][0],
|
||||
"message": ex.args[0][1]
|
||||
}
|
||||
|
||||
if len(ex.args) >= 2:
|
||||
data["error"]["related"] = ex.args[1]
|
||||
|
||||
return data
|
||||
except Exception:
|
||||
|
||||
except BaseException as err:
|
||||
traceback.print_exc()
|
||||
return {
|
||||
"error": {
|
||||
"code": API_ERROR_INTERNAL_ERROR[0],
|
||||
"message": API_ERROR_INTERNAL_ERROR[1]
|
||||
}
|
||||
data["error"] = {
|
||||
"code": API_ERROR_INTERNAL_ERROR[0],
|
||||
"message": API_ERROR_INTERNAL_ERROR[1],
|
||||
"related": f"Exception {type(err)}: {str(err)}"
|
||||
}
|
||||
return data
|
||||
|
@@ -102,6 +102,7 @@ def account_verify_phone(params):
|
||||
def account_get(params):
|
||||
user = _reqire_access_token(params)
|
||||
return api_make_response({
|
||||
"id": user.id,
|
||||
"name": user.name,
|
||||
"surname": user.surname,
|
||||
"email": user.email,
|
||||
@@ -152,7 +153,7 @@ api_methods = {
|
||||
"params": [
|
||||
|
||||
],
|
||||
"returns": "Поля пользователя (name, surname, email, phone, phone_verified)."
|
||||
"returns": "Поля пользователя (id, name, surname, email, phone, phone_verified)."
|
||||
},
|
||||
|
||||
"account.verifyPhone": {
|
||||
|
@@ -7,7 +7,7 @@ def __make_invalid_argument_type_error(name, value, except_type):
|
||||
|
||||
|
||||
def api_make_response(response):
|
||||
return {"response": API_OK_OBJ | response}
|
||||
return API_OK_OBJ | {"response": response}
|
||||
|
||||
|
||||
def api_get_param_int(params: dict, name: str, required=True, default=0):
|
||||
|
Reference in New Issue
Block a user