feat(integration-webhooktest): v0.11e+ wire up enhanceFromBackend (Phase C2)

integration/webhooktest.ts:
- import enhanceFromBackend + formatErrorLine
- 配置拉取失败 catch + 后端测试失败 catch 都用 enhanceFromBackend
- 输出格式统一: [step N name] field: CODE - message
This commit is contained in:
ssw committed 2026-06-27 03:47:54 +08:00
1 parent e8b7508e84
commit 249ef1b08c
1 file changed
+5 -2
+5 -2
View File
@@ -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 WebhookTestOpts {
configId?: string
@@ -38,7 +39,8 @@ export function buildIntegrationWebhookTestCommand(): Command {
// 走 AccountConfig 模式: 拉取 config + 测试
const configR = await c.get<Record<string, unknown>>(`/message/AccountConfig/${opts.configId}`)
if (configR.code !== 200 || !configR.data) {
log.error(`integration webhooktest 配置拉取失败: ${configR.msg || 'id 不存在'}`)
const enhanced = enhanceFromBackend(configR.msg || 'id 不存在', 'configId', { entity: 'integration' })
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '配置拉取' })}`)
process.exit(1)
}
body = {
@@ -64,7 +66,8 @@ export function buildIntegrationWebhookTestCommand(): Command {
const r = await c.postJson('/message/AccountConfig/testSendWebhook', body)
if (r.code !== 200) {
log.error(`integration webhooktest 失败: ${r.msg}`)
const enhanced = enhanceFromBackend(r.msg || '', 'webhook', { entity: 'integration' })
log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`)
process.exit(1)
}
log.info(`✓ Webhook 测试发送 OK (configId=${opts.configId || '-'}, url=${opts.url || '(from config)'})`)