Skip to content

Commit

Permalink
refactor: add missing error logs(view level) when getting repo failed
Browse files Browse the repository at this point in the history
  • Loading branch information
piglei committed Jul 25, 2024
1 parent 0d073e5 commit e72b46c
Showing 1 changed file with 11 additions and 1 deletion.
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)

0 comments on commit e72b46c

Please sign in to comment.