feat(integration-smstest): v0.11e+ wire up enhanceFromBackend (Phase C2)
integration/smstest.ts: - import enhanceFromBackend + formatErrorLine - 配置拉取失败 catch + 后端测试失败 catch 都用 enhanceFromBackend - 输出格式统一: [step N name] field: CODE - message
This commit is contained in:
1 parent
9354e50301
commit
e8b7508e84
1 file changed
+5
-2
@@ -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<Record<string, unknown>>(`/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})`)
|
||||
|
||||
Reference in new issue
Block a user