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
|
||||
|
||||
Reference in New Issue
Block a user