Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add missing error logs(view level) when getting repo failed #1489

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apiserver/paasng/paasng/platform/sourcectl/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ def get_repo_list(self, request, source_control_type):
except AccessTokenForbidden as e:
raise error_codes.CANNOT_GET_REPO.f(_("当前 AccessToken 无法获取到仓库列表,请检查后重试")) from e
except Exception as e:
logger.exception(
"Unknown error occurred when getting repo list, user_id: %s, sourcectl_type: %s",
request.user.pk,
source_control_type,
)
raise error_codes.CANNOT_GET_REPO.f(_("访问源码仓库失败,请联系项目管理员")) from e

return Response({"results": slzs.RepoSLZ(repos, many=True).data})
Expand Down Expand Up @@ -479,6 +484,7 @@ def get_compare_url(self, request, code, module_name, from_revision, to_revision
except AccessTokenForbidden:
raise error_codes.CANNOT_GET_REPO.f(_("AccessToken无权限访问该仓库, 请检查授权与其对应 Scope"))
except Exception as e:
logger.exception("Unknown error occurred when getting compare url, user_id: %s", request.user.pk)
raise error_codes.CANNOT_GET_REPO.f(_(f"仓库信息查询异常: {e}"))
return Response({"result": compare_url})

Expand Down Expand Up @@ -543,7 +549,11 @@ def retrieve(self, request, code, module_name, smart_revision):
except AccessTokenForbidden:
raise error_codes.CANNOT_GET_REPO.f(_("AccessToken无权限访问该仓库, 请检查授权与其对应 Scope"))
except Exception:
logger.exception("unable to fetch repo info")
logger.exception(
"Unknown error occurred when inspecting version, user_id: %s, version: %s",
request.user.pk,
smart_revision,
)
raise error_codes.CANNOT_GET_REPO.f(_("{module} 的仓库信息查询异常").format(module=module))
else:
return Response(data)