Add error IDs for unknown modules and unknown projects.
(cherry picked from commit 2adcfc9563
)
This commit is contained in:
parent
785ee7bcc3
commit
f67e2c5d52
@ -35,5 +35,11 @@ UNKNOWN_BLUEPRINT = "UnknownBlueprint"
|
||||
# Returned from the API when a commit that was requested does not exist.
|
||||
UNKNOWN_COMMIT = "UnknownCommit"
|
||||
|
||||
# Returned from the API when a module that was requested does not exist.
|
||||
UNKNOWN_MODULE = "UnknownModule"
|
||||
|
||||
# Returned from the API when a project that was requested does not exist.
|
||||
UNKNOWN_PROJECT = "UnknownProject"
|
||||
|
||||
# Returned from the API when a UUID that was requested does not exist.
|
||||
UNKNOWN_UUID = "UnknownUUID"
|
||||
|
@ -1508,6 +1508,11 @@ def v0_api(api):
|
||||
log.error("(v0_projects_info) %s", str(e))
|
||||
return jsonify(status=False, errors=[str(e)]), 400
|
||||
|
||||
if not projects:
|
||||
msg = "one of the requested projects does not exist: %s" % project_names
|
||||
log.error("(v0_projects_info) %s", msg)
|
||||
return jsonify(status=False, errors=[{"id": UNKNOWN_PROJECT, "msg": msg}]), 400
|
||||
|
||||
return jsonify(projects=projects)
|
||||
|
||||
@api.route("/api/v0/projects/depsolve", defaults={'project_names': ""})
|
||||
@ -1526,6 +1531,11 @@ def v0_api(api):
|
||||
log.error("(v0_projects_depsolve) %s", str(e))
|
||||
return jsonify(status=False, errors=[str(e)]), 400
|
||||
|
||||
if not deps:
|
||||
msg = "one of the requested projects does not exist: %s" % project_names
|
||||
log.error("(v0_projects_depsolve) %s", msg)
|
||||
return jsonify(status=False, errors=[{"id": UNKNOWN_PROJECT, "msg": msg}]), 400
|
||||
|
||||
return jsonify(projects=deps)
|
||||
|
||||
@api.route("/api/v0/projects/source/list")
|
||||
@ -1690,6 +1700,11 @@ def v0_api(api):
|
||||
log.error("(v0_modules_list) %s", str(e))
|
||||
return jsonify(status=False, errors=[str(e)]), 400
|
||||
|
||||
if module_names and not available:
|
||||
msg = "one of the requested modules does not exist: %s" % module_names
|
||||
log.error("(v0_modules_list) %s", msg)
|
||||
return jsonify(status=False, errors=[{"id": UNKNOWN_MODULE, "msg": msg}]), 400
|
||||
|
||||
modules = take_limits(available, offset, limit)
|
||||
return jsonify(modules=modules, offset=offset, limit=limit, total=len(available))
|
||||
|
||||
@ -1711,7 +1726,7 @@ def v0_api(api):
|
||||
if not modules:
|
||||
msg = "one of the requested modules does not exist: %s" % module_names
|
||||
log.error("(v0_modules_info) %s", msg)
|
||||
return jsonify(status=False, errors=[msg]), 400
|
||||
return jsonify(status=False, errors=[{"id": UNKNOWN_MODULE, "msg": msg}]), 400
|
||||
|
||||
return jsonify(modules=modules)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user