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

Use 500 as the error code if there is an error generating SDKs #65

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ def generate(self, request, gateway_id):
raise error_codes.SDK_ERROR.format(_("网关下无资源(请求方法非 ANY),无法生成 SDK。"), replace=True)
raise error_codes.SDK_ERROR.format(_("网关下无资源(公开,且请求方法非 ANY),无法生成 SDK。"), replace=True)
except exceptions.GenerateError:
raise error_codes.SDK_ERROR.format(_("网关 SDK 生成失败。"), replace=True)
raise error_codes.SDK_INTERNAL_ERROR.format(_("网关 SDK 生成失败。"), replace=True)
except exceptions.PackError:
raise error_codes.SDK_ERROR.format(_("网关 SDK 打包失败。"), replace=True)
raise error_codes.SDK_INTERNAL_ERROR.format(_("网关 SDK 打包失败。"), replace=True)
except exceptions.DistributeError:
raise error_codes.SDK_ERROR.format(_("网关 SDK 发布失败。"), replace=True)
raise error_codes.SDK_INTERNAL_ERROR.format(_("网关 SDK 发布失败。"), replace=True)
except exceptions.TooManySDKVersion as err:
raise error_codes.SDK_ERROR.format(
_("同一资源版本,最多只能生成 {count} 个 SDK。").format(count=err.max_count),
Expand Down
3 changes: 3 additions & 0 deletions src/dashboard/apigateway/apigateway/common/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def __getattr__(self, code_name):
ErrorCode("SDK_ERROR", 50100, _("网关SDK生成或上传失败")),
ErrorCode("RESOURCE_DOC_EXPORT_ERROR", 50101, _("网关文档导出失败")),
ErrorCode("RESOURCE_DOC_IMPORT_ERROR", 50102, _("资源文档导入失败")),
ErrorCode(
"SDK_INTERNAL_ERROR", 50103, _("处理 SDK 请求时发生内部错误"), status_code=status.HTTP_500_INTERNAL_SERVER_ERROR
),
# ESB 对应的网关不存在
ErrorCode("COMPONENT_GATEWAY_NOT_FOUND", 50203, _("组件对应的网关 [name={api_name}] 不存在")),
ErrorCode("COMPONENT_METHOD_INVALID", 50204, _("组件请求方法配置错误")),
Expand Down
3 changes: 2 additions & 1 deletion src/dashboard/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ build-backend = "poetry.masonry.api"
[tool.ruff]
# Enable Pyflakes `E` and `F` codes by default.
select = ["E", "F", "W"]
ignore = ["E741", "F841"]
# Disable E501 until this issue is fixed: https://github.com/astral-sh/ruff/issues/3825
ignore = ["E741", "F841", "E501"]

# Exclude a variety of commonly ignored directories.
exclude = [
Expand Down