gx
chenyc
5 天以前 747a86bb94006aaca721cfc0c0ce7061643a9ea6
aliyun-service.js
@@ -63,7 +63,7 @@
    const normalized = this.normalizeEventPayload(errorLike);
    if (normalized instanceof Error) {
      return normalized.message || normalized.name || 'unknown-error';
      return normalized.message || normalized.name || '未知错误';
    }
    if (Array.isArray(normalized)) {
@@ -71,7 +71,7 @@
        .map((item) => this.formatErrorMessage(item))
        .filter(Boolean);
      return parts.length > 0 ? parts.join(' | ') : 'unknown-error';
      return parts.length > 0 ? parts.join(' | ') : '未知错误';
    }
    if (normalized && typeof normalized === 'object') {
@@ -87,7 +87,7 @@
    }
    if (normalized === undefined || normalized === null || normalized === '') {
      return 'unknown-error';
      return '未知错误';
    }
    return String(normalized);
@@ -139,7 +139,7 @@
      return this.aliyunSdk;
    }
    // eslint-disable-next-line global-require
    // 延迟加载 SDK,避免未启用阿里云时引入额外依赖。
    this.aliyunSdk = require('aliyun-iot-device-sdk');
    return this.aliyunSdk;
  }
@@ -219,7 +219,7 @@
    try {
      responseBody = JSON.parse(rawText);
    } catch (_error) {
      throw new Error('三元组接口返回不是有效 JSON');
      throw new Error('三元组接口返回的不是有效 JSON');
    }
    return this.extractTuple(responseBody, deviceId);
@@ -241,7 +241,7 @@
    if (context.lastRegisterAttempt > 0 && (now - context.lastRegisterAttempt) < retryMs && context.lastRegisterError) {
      this.logger.warn(`[ALIYUN] 三元组请求冷却中 deviceId=${device.deviceId} retryMs=${retryMs} lastError=${context.lastRegisterError}`);
      throw new Error(`阿里云三元组重试冷却中 ${context.lastRegisterError}`);
      throw new Error(`阿里云三元组重试冷却中: ${context.lastRegisterError}`);
    }
    context.lastRegisterAttempt = now;