From e8b7508e84faec52c64c959fce5d461212f1e0ea Mon Sep 17 00:00:00 2001 From: ssw Date: Sat, 27 Jun 2026 03:47:11 +0800 Subject: [PATCH] feat(integration-smstest): v0.11e+ wire up enhanceFromBackend (Phase C2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit integration/smstest.ts: - import enhanceFromBackend + formatErrorLine - 配置拉取失败 catch + 后端测试失败 catch 都用 enhanceFromBackend - 输出格式统一: [step N name] field: CODE - message --- src/commands/integration/smstest.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands/integration/smstest.ts b/src/commands/integration/smstest.ts index e9f4559..48f6584 100644 --- a/src/commands/integration/smstest.ts +++ b/src/commands/integration/smstest.ts @@ -11,6 +11,7 @@ import { Command } from 'commander' import { JnpfClient } from '../../core/client.ts' import { installAiHelpHook } from '../../core/help.ts' import { log } from '../../core/log.ts' +import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts' interface SmsTestOpts { configId: string @@ -31,7 +32,8 @@ export function buildIntegrationSmsTestCommand(): Command { // 1. 拉取 config 详情 const configR = await c.get>(`/message/AccountConfig/${opts.configId}`) if (configR.code !== 200 || !configR.data) { - log.error(`integration smstest 配置拉取失败: ${configR.msg || 'id 不存在'}`) + const enhanced = enhanceFromBackend(configR.msg || 'id 不存在', 'configId', { entity: 'integration' }) + log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '配置拉取' })}`) process.exit(1) } const config = configR.data @@ -49,7 +51,8 @@ export function buildIntegrationSmsTestCommand(): Command { // 3. 走 AccountConfig/testSendSms const r = await c.postJson('/message/AccountConfig/testSendSms', body) if (r.code !== 200) { - log.error(`integration smstest 失败: ${r.msg}`) + const enhanced = enhanceFromBackend(r.msg || '', 'sms', { entity: 'integration' }) + log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`) process.exit(1) } log.info(`✓ 短信测试发送 OK (configId=${opts.configId}, to=${opts.phone})`)