diff --git a/src/dashboard/apigateway/apigateway/apps/support/api_sdk/views.py b/src/dashboard/apigateway/apigateway/apps/support/api_sdk/views.py index b6f1123bf..23854de24 100644 --- a/src/dashboard/apigateway/apigateway/apps/support/api_sdk/views.py +++ b/src/dashboard/apigateway/apigateway/apps/support/api_sdk/views.py @@ -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), diff --git a/src/dashboard/apigateway/apigateway/common/error_codes.py b/src/dashboard/apigateway/apigateway/common/error_codes.py index 7e389bdc2..44b572590 100644 --- a/src/dashboard/apigateway/apigateway/common/error_codes.py +++ b/src/dashboard/apigateway/apigateway/common/error_codes.py @@ -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, _("组件请求方法配置错误")), diff --git a/src/dashboard/pyproject.toml b/src/dashboard/pyproject.toml index 36e7f2f47..18d04a06c 100644 --- a/src/dashboard/pyproject.toml +++ b/src/dashboard/pyproject.toml @@ -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 = [