@cloudbase/manager-node 5.8.9-beta.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.codebuddy/rules/error-code-contract.mdc +13 -0
  2. package/CHANGELOG.md +1 -0
  3. package/lib/agent/index.js +6 -5
  4. package/lib/aiModel/index.js +21 -9
  5. package/lib/cloudApp/index.js +4 -4
  6. package/lib/cloudrun/index.js +16 -15
  7. package/lib/common/index.js +1 -1
  8. package/lib/database/index.js +23 -23
  9. package/lib/deploy/DatabaseDeployer.js +19 -24
  10. package/lib/deploy/DeployOrchestrator.js +2 -2
  11. package/lib/deploy/FunctionDeployer.js +19 -1
  12. package/lib/deploy/GatewayDeployer.js +5 -5
  13. package/lib/deploy/StaticDeployer.js +2 -2
  14. package/lib/deploy/framework.js +2 -1
  15. package/lib/deploy/function/config-guard.js +23 -3
  16. package/lib/deploy/function/enterprise-tcr.js +18 -2
  17. package/lib/docs/index.js +4 -3
  18. package/lib/env/index.js +16 -16
  19. package/lib/environment.js +4 -4
  20. package/lib/environmentManager.js +5 -1
  21. package/lib/error-docs.js +385 -0
  22. package/lib/error-types.js +21 -0
  23. package/lib/error.js +239 -2
  24. package/lib/function/index.js +135 -41
  25. package/lib/function/packer.js +1 -1
  26. package/lib/hosting/index.js +1 -1
  27. package/lib/index.js +2 -1
  28. package/lib/integration/crypto.js +4 -3
  29. package/lib/integration/index.js +1 -1
  30. package/lib/integration/secretKey.js +4 -4
  31. package/lib/monitor/index.js +1 -1
  32. package/lib/mysql/index.js +2 -1
  33. package/lib/permission/index.js +56 -49
  34. package/lib/platform/index.js +2 -2
  35. package/lib/sandbox/index.js +68 -61
  36. package/lib/storage/index.js +164 -162
  37. package/lib/user/index.js +32 -31
  38. package/lib/utils/cloud-api-request.js +13 -5
  39. package/lib/utils/cloudbase-request.js +21 -0
  40. package/lib/utils/fs.js +3 -3
  41. package/lib/utils/http-request.js +2 -2
  42. package/lib/utils/index.js +4 -3
  43. package/lib/utils/storage-config.js +3 -3
  44. package/package.json +2 -2
  45. package/types/error-docs.d.ts +57 -0
  46. package/types/error-types.d.ts +32 -0
  47. package/types/error.d.ts +148 -2
  48. package/types/function/index.d.ts +14 -1
  49. package/types/utils/cloudbase-request.d.ts +22 -0
@@ -144,25 +144,25 @@ class GatewayDeployer {
144
144
  // 保留前缀检测(对齐控制台 useRouteConfig 与 tcb routes add):/__auth、/.well-known 是系统保留前缀
145
145
  const reservedPrefix = /^\/(__auth|\.well-known)/;
146
146
  if (reservedPrefix.test(path)) {
147
- throw new error_1.CloudBaseError(`网关路由 path 不能使用系统保留前缀:${path}。/__auth、/.well-known 是系统保留前缀,请更换其他路径`);
147
+ (0, error_1.throwInvalidParam)(`网关路由 path 不能使用系统保留前缀:${path}。/__auth、/.well-known 是系统保留前缀,请更换其他路径`);
148
148
  }
149
149
  // path 格式校验(与控制台 useRouteConfig、tcb routes add 一致)
150
150
  const pathPattern = /^(\/(?!\/)[a-zA-Z0-9_\.\-]{0,50})+\/?$/;
151
151
  if (!pathPattern.test(path)) {
152
- throw new error_1.CloudBaseError(`网关路由 path 格式错误:${path}。必须以 "/" 开头,每段只含字母/数字/./_/-,每段≤50字符,不支持通配符 *(示例:/api、/pay-common、/)`);
152
+ (0, error_1.throwInvalidParam)(`网关路由 path 格式错误:${path}。必须以 "/" 开头,每段只含字母/数字/./_/-,每段≤50字符,不支持通配符 *(示例:/api、/pay-common、/)`);
153
153
  }
154
154
  const match = /^(function|hosting):(.+)$/.exec(target);
155
155
  if (!match) {
156
- throw new error_1.CloudBaseError(`网关路由 target 格式错误:${target},仅支持 function:<name> / hosting:<name>`);
156
+ (0, error_1.throwInvalidParam)(`网关路由 target 格式错误:${target},仅支持 function:<name> / hosting:<name>`);
157
157
  }
158
158
  const [, type, name] = match;
159
159
  if (!name) {
160
- throw new error_1.CloudBaseError(`网关路由 target 缺少资源名:${target}`);
160
+ (0, error_1.throwInvalidParam)(`网关路由 target 缺少资源名:${target}`);
161
161
  }
162
162
  // 静态托管:上游名固定为 staticstore,且只支持一级路径(与 tcb routes add 一致)
163
163
  if (type === 'hosting') {
164
164
  if (!/^\/[a-zA-Z0-9_\.\-]{0,50}\/?$/.test(path)) {
165
- throw new error_1.CloudBaseError(`静态托管路由只支持一级路径(如 / 或 /web),当前值:${path}`);
165
+ (0, error_1.throwInvalidParam)(`静态托管路由只支持一级路径(如 / 或 /web),当前值:${path}`);
166
166
  }
167
167
  return Object.assign({ Path: path, UpstreamResourceType: 'STATIC_STORE', UpstreamResourceName: 'staticstore', EnableSafeDomain: true, EnableAuth: enableAuth !== null && enableAuth !== void 0 ? enableAuth : false, EnablePathTransmission: enablePathTransmission !== null && enablePathTransmission !== void 0 ? enablePathTransmission : false, Enable: true }, (qpsPolicy ? { QPSPolicy: qpsPolicy } : {}));
168
168
  }
@@ -39,7 +39,7 @@ class StaticDeployer {
39
39
  const { config, cwd = process.cwd() } = options;
40
40
  const serviceName = config.serviceName;
41
41
  if (!serviceName) {
42
- throw new error_1.CloudBaseError('app 部署需要配置 serviceName');
42
+ (0, error_1.throwInvalidParam)('app 部署需要配置 serviceName');
43
43
  }
44
44
  const projectPath = path_1.default.resolve(cwd, config.root || '.');
45
45
  const resolvedDeployPath = config.deployPath || `/${serviceName}`;
@@ -208,7 +208,7 @@ class StaticDeployer {
208
208
  }
209
209
  catch (e) {
210
210
  const detail = ((e === null || e === void 0 ? void 0 : e.stderr) || (e === null || e === void 0 ? void 0 : e.stdout) || (e === null || e === void 0 ? void 0 : e.message) || String(e)).toString().trim();
211
- throw new error_1.CloudBaseError(`本地构建失败:在 ${projectPath} 执行「${buildCommand}」失败。\n` +
211
+ (0, error_1.throwApiError)(`本地构建失败:在 ${projectPath} 执行「${buildCommand}」失败。\n` +
212
212
  `请先在项目目录手动执行该命令排查原因(常见原因:构建脚本报错、依赖未安装、lockfile 不一致)。\n` +
213
213
  (detail ? `原始错误:${detail.slice(0, 500)}` : ''));
214
214
  }
@@ -42,6 +42,7 @@ exports.buildHostingItem = buildHostingItem;
42
42
  const fs = __importStar(require("fs"));
43
43
  const path = __importStar(require("path"));
44
44
  const child_process_1 = require("child_process");
45
+ const error_1 = require("../error");
45
46
  /**
46
47
  * 框架 → 默认构建命令映射(hosting 本地构建 / app 云端构建复用)
47
48
  */
@@ -258,7 +259,7 @@ function buildHostingItem(config, root, envVariables) {
258
259
  }
259
260
  catch (e) {
260
261
  const detail = ((e === null || e === void 0 ? void 0 : e.stderr) || (e === null || e === void 0 ? void 0 : e.stdout) || (e === null || e === void 0 ? void 0 : e.message) || String(e)).toString().trim();
261
- throw new Error(`本地构建失败:在 ${root} 执行「${buildCommand}」失败。\n${detail.slice(0, 500)}`);
262
+ throw new error_1.CloudBaseError(`本地构建失败:在 ${root} 执行「${buildCommand}」失败。\n${detail.slice(0, 500)}`, { code: 'BUILD_FAILED', source: 'manager-node' });
262
263
  }
263
264
  return resolveHostingOutputDir(config, root);
264
265
  }
@@ -501,7 +501,9 @@ function checkImageReference(imageConfig, checks) {
501
501
  return;
502
502
  }
503
503
  if (parsed.tag === 'latest' && !parsed.digest) {
504
- checks.push(fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TAG_LATEST_FORBIDDEN, '镜像地址禁止使用 latest', '请使用内容可追溯的不可变 tag 或 digest'));
504
+ // D7:平台**允许** latest —— 它是「次优/有风险」而非「必然失败」,按 §4.4 判据应**提示**而非拦截。
505
+ // 走 fail 会违反 AIP-163「fail 必须蕴含真实失败」,属把建议误当校验(归类纠错)。
506
+ checks.push(warn(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TAG_LATEST_FORBIDDEN, '镜像地址使用了 latest(内容不可追溯)', '建议使用不可变 tag 或 digest,以便部署可重试、可回滚'));
505
507
  }
506
508
  }
507
509
  /**
@@ -561,8 +563,9 @@ function checkBuildTag(raw, build) {
561
563
  return [fail(types_1.FUNCTION_DEPLOY_ERROR.BUILD_TAG_INVALID, '镜像 tag 不合法')];
562
564
  }
563
565
  if (build.tag === 'latest') {
566
+ // D7:同前 —— 平台允许 latest,故为「提示」而非「拦截」(AIP-163)
564
567
  return [
565
- fail(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TAG_LATEST_FORBIDDEN, '镜像 tag 禁止使用 latest', '请使用不可变 tag,或不指定 tag 由构建器生成时间戳 tag')
568
+ warn(types_1.FUNCTION_DEPLOY_ERROR.IMAGE_TAG_LATEST_FORBIDDEN, '镜像 tag 使用了 latest(内容不可追溯)', '建议改用不可变 tag,或不指定 tag 由构建器生成时间戳 tag')
566
569
  ];
567
570
  }
568
571
  return [];
@@ -804,6 +807,15 @@ function assertDeployConfig(config) {
804
807
  const report = checkDeployConfig(config);
805
808
  if (!report.ready) {
806
809
  const failures = report.checks.filter(item => item.status === 'fail');
810
+ // ⚠️ 同 FunctionDeployer.assertPreflightReady:报告不自洽(ready=false 但无 fail 项)时
811
+ // `failures` 为空数组,取 `failures[0].id` 会先抛 TypeError(代码评审:边界条件)。
812
+ if (failures.length === 0) {
813
+ failures.push({
814
+ id: 'CHECK_REPORT_INCONSISTENT',
815
+ status: 'fail',
816
+ summary: '部署配置校验未通过,但未给出具体失败项,请重试或用 --debug 查看完整报告'
817
+ });
818
+ }
807
819
  const message = failures
808
820
  .map(item => {
809
821
  const remediation = item.remediation ? `,${item.remediation}` : '';
@@ -811,7 +823,15 @@ function assertDeployConfig(config) {
811
823
  })
812
824
  .join('\n');
813
825
  throw new error_1.CloudBaseError(`部署配置校验未通过:\n${message}`, {
814
- code: failures[0].id
826
+ code: failures[0].id,
827
+ // code 只能承载第一个失败项,meta.failures 保留全量(埋点才能统计真实分布)
828
+ meta: {
829
+ failures: failures.map(item => ({
830
+ code: item.id,
831
+ summary: item.summary,
832
+ remediation: item.remediation
833
+ }))
834
+ }
815
835
  });
816
836
  }
817
837
  return normalizeDeployConfig(config);
@@ -6,6 +6,7 @@ exports.createTcrApiService = createTcrApiService;
6
6
  const error_1 = require("../../error");
7
7
  const types_1 = require("../types");
8
8
  const config_guard_1 = require("./config-guard");
9
+ const cam_preflight_1 = require("./cam-preflight");
9
10
  const TCR_API_VERSION = '2019-09-24';
10
11
  const NAMESPACE_PATTERN = /^[a-z0-9](?:[a-z0-9]|[._-](?![._-])){0,28}[a-z0-9]$/;
11
12
  function responseOf(result) {
@@ -64,9 +65,18 @@ async function resolveRegistry(service, region, explicitRegistryId) {
64
65
  });
65
66
  }
66
67
  catch (error) {
68
+ // AIP-193:权限错误必须**保持权限语义**,不得包装成「实例发现失败」这类业务错误 ——
69
+ // 否则用户与埋点都看不到「无权限」这个真实原因。直接透传上游错误
70
+ // (其 code 为 AuthFailure.*,source 为 cloud-api,requestId 完整)。
71
+ if ((0, cam_preflight_1.isCamPermissionError)(error)) {
72
+ throw error;
73
+ }
67
74
  throw new error_1.CloudBaseError('查询企业版 TCR 实例失败,请确认当前身份具备 DescribeInstances 权限。', {
68
75
  code: types_1.FUNCTION_DEPLOY_ERROR.TCR_INSTANCE_DISCOVERY_FAILED,
69
- requestId: errorRequestId(error) || ''
76
+ source: 'manager-node',
77
+ requestId: errorRequestId(error) || '',
78
+ // 保留上游错误:不挂 cause 链会让排查丢失最关键的原始 code / requestId
79
+ original: error instanceof Error ? error : undefined
70
80
  });
71
81
  }
72
82
  const response = responseOf(result);
@@ -179,9 +189,15 @@ async function createEnterpriseTcrCredential(service, registryId) {
179
189
  });
180
190
  }
181
191
  catch (error) {
192
+ // AIP-193:权限错误保持权限语义(同上)—— 透传上游错误,不包装成「凭证创建失败」
193
+ if ((0, cam_preflight_1.isCamPermissionError)(error)) {
194
+ throw error;
195
+ }
182
196
  throw new error_1.CloudBaseError('获取企业版 TCR 临时登录凭证失败,请确认当前身份具备 CreateInstanceToken 权限。', {
183
197
  code: types_1.FUNCTION_DEPLOY_ERROR.TCR_TOKEN_CREATE_FAILED,
184
- requestId: errorRequestId(error) || ''
198
+ source: 'manager-node',
199
+ requestId: errorRequestId(error) || '',
200
+ original: error instanceof Error ? error : undefined
185
201
  });
186
202
  }
187
203
  const response = responseOf(result);
package/lib/docs/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocsService = void 0;
4
4
  const http_request_1 = require("../utils/http-request");
5
+ const error_1 = require("../error");
5
6
  const DOCS_BASE_URL = 'https://docs.cloudbase.net';
6
7
  const CATEGORY_URL = `${DOCS_BASE_URL}/category.json`;
7
8
  const ALGOLIA_SEARCH_URL = 'https://70wjvl90pg-dsn.algolia.net/1/indexes/*/queries' +
@@ -45,7 +46,7 @@ class DocsService {
45
46
  if (found) {
46
47
  return found;
47
48
  }
48
- throw new Error(`Module "${moduleName}" not found`);
49
+ (0, error_1.throwNotFound)(`Module "${moduleName}" not found`);
49
50
  }
50
51
  /**
51
52
  * Case: tcb docs read <任意输入>
@@ -72,7 +73,7 @@ class DocsService {
72
73
  if (result) {
73
74
  return result;
74
75
  }
75
- throw new Error(`未找到模块或文档 "${input}"`);
76
+ (0, error_1.throwNotFound)(`未找到模块或文档 "${input}"`);
76
77
  }
77
78
  // 模式3: 模块名查找(顶级或嵌套)复用上面已获取的 category
78
79
  const topLevelModule = category[input];
@@ -93,7 +94,7 @@ class DocsService {
93
94
  if (prefixResult) {
94
95
  return prefixResult;
95
96
  }
96
- throw new Error(`未找到模块或文档 "${input}"`);
97
+ (0, error_1.throwNotFound)(`未找到模块或文档 "${input}"`);
97
98
  }
98
99
  async readDoc(docPath) {
99
100
  const normalizedPath = docPath.endsWith('.md') ? docPath : `${docPath}/index.md`;
package/lib/env/index.js CHANGED
@@ -301,7 +301,7 @@ class EnvService {
301
301
  const validStatus = ['ENABLE', 'DISABLE'];
302
302
  let finalAppSecret = appSecret;
303
303
  if (!validStatus.includes(status)) {
304
- throw new error_1.CloudBaseError(`Invalid status value: ${status}. Only support 'ENABLE', 'DISABLE'`);
304
+ (0, error_1.throwInvalidParam)(`Invalid status value: ${status}. Only support 'ENABLE', 'DISABLE'`);
305
305
  }
306
306
  const params = {
307
307
  EnvId: this.envId,
@@ -457,7 +457,7 @@ class EnvService {
457
457
  async getAdminAccessToken(credentials) {
458
458
  const { secretId, secretKey, token } = credentials || this.environment.cloudBaseContext;
459
459
  if (!secretId || !secretKey) {
460
- throw new error_1.CloudBaseError('missing secretId or secretKey of tencent cloud');
460
+ (0, error_1.throwInvalidParam)('missing secretId or secretKey of tencent cloud');
461
461
  }
462
462
  const envId = this.envId;
463
463
  const cacheKey = `access_token_secret_${envId}_${secretId}`;
@@ -567,7 +567,7 @@ class EnvService {
567
567
  });
568
568
  const packageInfo = (_a = packageRes.PackageList) === null || _a === void 0 ? void 0 : _a[0];
569
569
  if (!packageInfo) {
570
- throw new error_1.CloudBaseError(`Invalid package id: ${packageId}`);
570
+ (0, error_1.throwInvalidParam)(`Invalid package id: ${packageId}`);
571
571
  }
572
572
  const { BillTags: billTags } = packageInfo;
573
573
  const newBillTag = this.parseBillTags(billTags);
@@ -595,7 +595,7 @@ class EnvService {
595
595
  });
596
596
  const priceInfo = (_c = priceRes.PriceInfos) === null || _c === void 0 ? void 0 : _c[0];
597
597
  if (!priceInfo) {
598
- throw new error_1.CloudBaseError(`Invalid package id: ${packageId}`);
598
+ (0, error_1.throwInvalidParam)(`Invalid package id: ${packageId}`);
599
599
  }
600
600
  return priceInfo;
601
601
  }
@@ -620,11 +620,11 @@ class EnvService {
620
620
  const envBaseInfo = (_a = envInfoRes === null || envInfoRes === void 0 ? void 0 : envInfoRes.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo;
621
621
  const billingInfo = (_b = billingRes.EnvBillingInfoList) === null || _b === void 0 ? void 0 : _b[0];
622
622
  if (!(envBaseInfo === null || envBaseInfo === void 0 ? void 0 : envBaseInfo.EnvId) || !billingInfo) {
623
- throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
623
+ (0, error_1.throwInvalidParam)(`Invalid env id: ${envId}`);
624
624
  }
625
625
  const packageInfo = (_c = packageRes.PackageList) === null || _c === void 0 ? void 0 : _c.find(item => item.PackageName === envBaseInfo.PackageId);
626
626
  if (!packageInfo) {
627
- throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
627
+ (0, error_1.throwInvalidParam)(`Invalid env id: ${envId}`);
628
628
  }
629
629
  const region = envBaseInfo.Region;
630
630
  const extPackageData = ((_d = billingInfo.ExtPackageCode) === null || _d === void 0 ? void 0 : _d.reduce((acc, { Code, Num }) => {
@@ -649,7 +649,7 @@ class EnvService {
649
649
  });
650
650
  const priceInfo = (_f = priceRes.PriceInfos) === null || _f === void 0 ? void 0 : _f[0];
651
651
  if (!priceInfo) {
652
- throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
652
+ (0, error_1.throwInvalidParam)(`Invalid env id: ${envId}`);
653
653
  }
654
654
  return priceInfo;
655
655
  }
@@ -674,15 +674,15 @@ class EnvService {
674
674
  const envBaseInfo = (_a = envInfoRes === null || envInfoRes === void 0 ? void 0 : envInfoRes.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo;
675
675
  const billingInfo = (_b = billingRes.EnvBillingInfoList) === null || _b === void 0 ? void 0 : _b[0];
676
676
  if (!(envBaseInfo === null || envBaseInfo === void 0 ? void 0 : envBaseInfo.EnvId) || !billingInfo || !billingInfo.PackageId) {
677
- throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
677
+ (0, error_1.throwInvalidParam)(`Invalid env id: ${envId}`);
678
678
  }
679
679
  const oldPackageInfo = (_c = packageRes.PackageList) === null || _c === void 0 ? void 0 : _c.find(item => item.PackageName === billingInfo.PackageId);
680
680
  if (!oldPackageInfo) {
681
- throw new error_1.CloudBaseError(`Modification for this package is not available`);
681
+ (0, error_1.throwApiError)(`Modification for this package is not available`);
682
682
  }
683
683
  const newPackageInfo = (_d = packageRes.PackageList) === null || _d === void 0 ? void 0 : _d.find(item => item.PackageName === newPackageId);
684
684
  if (!newPackageInfo) {
685
- throw new error_1.CloudBaseError(`Invalid package id: ${newPackageId}`);
685
+ (0, error_1.throwInvalidParam)(`Invalid package id: ${newPackageId}`);
686
686
  }
687
687
  const region = envBaseInfo.Region;
688
688
  const newBillTags = this.parseBillTags(newPackageInfo.BillTags);
@@ -737,7 +737,7 @@ class EnvService {
737
737
  });
738
738
  const priceInfo = (_g = priceRes.PriceInfos) === null || _g === void 0 ? void 0 : _g[0];
739
739
  if (!priceInfo) {
740
- throw new error_1.CloudBaseError(`Invalid package id: ${newPackageId}`);
740
+ (0, error_1.throwInvalidParam)(`Invalid package id: ${newPackageId}`);
741
741
  }
742
742
  return priceInfo;
743
743
  }
@@ -780,11 +780,11 @@ class EnvService {
780
780
  */
781
781
  async describeCertificates(params = {}) {
782
782
  if (params.Offset !== undefined && (!Number.isInteger(params.Offset) || params.Offset < 0)) {
783
- throw new error_1.CloudBaseError('Offset 必须是大于等于 0 的整数');
783
+ (0, error_1.throwInvalidParam)('Offset 必须是大于等于 0 的整数');
784
784
  }
785
785
  if (params.Limit !== undefined &&
786
786
  (!Number.isInteger(params.Limit) || params.Limit < 1 || params.Limit > 1000)) {
787
- throw new error_1.CloudBaseError('Limit 必须是 1 至 1000 的整数');
787
+ (0, error_1.throwInvalidParam)('Limit 必须是 1 至 1000 的整数');
788
788
  }
789
789
  return this.certificateCloudService.request('DescribeCertificates', params);
790
790
  }
@@ -894,13 +894,13 @@ class EnvService {
894
894
  const domains = queryRes.Domains || [];
895
895
  const targetDomain = domains.find(d => d.Domain === Domain);
896
896
  if (!targetDomain) {
897
- throw new error_1.CloudBaseError(`Domain ${Domain} does not exist`);
897
+ (0, error_1.throwNotFound)(`Domain ${Domain} does not exist`);
898
898
  }
899
899
  // 检查是否有路由绑定
900
900
  const routes = targetDomain.Routes || [];
901
901
  if (routes.length > 0) {
902
902
  const routePaths = routes.map(r => r.Path).join(', ');
903
- throw new error_1.CloudBaseError(`Domain ${Domain} has ${routes.length} route binding(s) (${routePaths}). Please delete the routes before deleting the domain.`);
903
+ (0, error_1.throwApiError)(`Domain ${Domain} has ${routes.length} route binding(s) (${routePaths}). Please delete the routes before deleting the domain.`);
904
904
  }
905
905
  // 无路由绑定,可以删除域名
906
906
  return this.cloudService.request('DeleteHTTPServiceRoute', {
@@ -986,7 +986,7 @@ class EnvService {
986
986
  return JSON.parse(billTags);
987
987
  }
988
988
  catch (e) {
989
- throw new error_1.CloudBaseError(`Failed to parse BillTags: ${billTags}`);
989
+ (0, error_1.throwApiError)(`Failed to parse BillTags: ${billTags}`);
990
990
  }
991
991
  }
992
992
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Environment = void 0;
4
4
  const database_1 = require("./database");
5
+ const error_1 = require("./error");
5
6
  const function_1 = require("./function");
6
7
  const FunctionDeployer_1 = require("./deploy/FunctionDeployer");
7
8
  const cloudrun_1 = require("./cloudrun");
@@ -10,7 +11,6 @@ const storage_1 = require("./storage");
10
11
  const env_1 = require("./env");
11
12
  const common_1 = require("./common");
12
13
  const log_1 = require("./log");
13
- const error_1 = require("./error");
14
14
  const constant_1 = require("./constant");
15
15
  const utils_1 = require("./utils");
16
16
  const hosting_1 = require("./hosting");
@@ -61,7 +61,7 @@ class Environment {
61
61
  return envConfig.getEnvInfo().then(envInfo => {
62
62
  this.lazyEnvironmentConfig = envInfo.EnvInfo;
63
63
  if (!this.lazyEnvironmentConfig.EnvId) {
64
- throw new error_1.CloudBaseError(`Environment ${this.envId} not found`);
64
+ (0, error_1.throwNotFound)(`Environment ${this.envId} not found`);
65
65
  }
66
66
  this.inited = true;
67
67
  return this.lazyEnvironmentConfig;
@@ -169,10 +169,10 @@ class Environment {
169
169
  const envToken = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SESSIONTOKEN);
170
170
  if (!envSecretId || !envSecretKey) {
171
171
  if ((0, utils_1.getRuntime)() === constant_1.RUN_ENV.SCF) {
172
- throw new Error('missing authoration key, redeploy the function');
172
+ (0, error_1.throwCredentialError)('missing authorization key, redeploy the function');
173
173
  }
174
174
  else {
175
- throw new Error('missing secretId or secretKey of tencent cloud');
175
+ (0, error_1.throwCredentialError)('missing secretId or secretKey of tencent cloud');
176
176
  }
177
177
  }
178
178
  else {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EnvironmentManager = void 0;
4
4
  const environment_1 = require("./environment");
5
5
  const constant_1 = require("./constant");
6
+ const error_1 = require("./error");
6
7
  class EnvironmentManager {
7
8
  constructor(context) {
8
9
  this.envs = {};
@@ -11,7 +12,10 @@ class EnvironmentManager {
11
12
  }
12
13
  getCurrentEnv() {
13
14
  if (!this.currentEnv) {
14
- throw new Error(constant_1.ERROR.CURRENT_ENVIRONMENT_IS_NULL);
15
+ throw new error_1.CloudBaseError(constant_1.ERROR.CURRENT_ENVIRONMENT_IS_NULL, {
16
+ code: 'CONFIG_ERROR',
17
+ source: 'manager-node'
18
+ });
15
19
  }
16
20
  return this.currentEnv;
17
21
  }