From 20c2df2a602d4b3d008ba5a4335b74868709cd4b Mon Sep 17 00:00:00 2001 From: ssw Date: Sat, 27 Jun 2026 04:11:24 +0800 Subject: [PATCH] feat(dict-dataupdate): v0.11e+ enhanceFromBackend (Phase C2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dict/dataupdate.ts: 加 enhanceFromBackend (EXIST007 字典项编码重复 等) --- src/commands/dict/dataupdate.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands/dict/dataupdate.ts b/src/commands/dict/dataupdate.ts index 404cada..30e1601 100644 --- a/src/commands/dict/dataupdate.ts +++ b/src/commands/dict/dataupdate.ts @@ -9,6 +9,7 @@ import { JnpfClient } from '../../core/client.ts' import { installAiHelpHook } from '../../core/help.ts' import { log, printJson } from '../../core/log.ts' import { initWebapi, loadDict } from '../../webapi/dict.ts' +import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts' interface Opts { id: string @@ -35,7 +36,8 @@ export function buildDictDataUpdateCommand(): Command { // v0.11+ Phase 2: 用 webapi 镜像 (loadDict.getDictionaryDataInfo + updateDictionaryData) const orig = (await loadDict.getDictionaryDataInfo(opts.id)) as Record if (!orig) { - log.error(`dict dataUpdate 失败: 拉原字典项 id=${opts.id} 失败`) + const enhanced = enhanceFromBackend('拉原字典项失败, id 不存在', 'id', { entity: 'dict' }) + log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '配置拉取' })}`) process.exit(1) } const body: Record = { ...orig, id: opts.id } @@ -46,7 +48,8 @@ export function buildDictDataUpdateCommand(): Command { log.info(`loadDict.updateDictionaryData (id=${opts.id})`) const r = (await loadDict.updateDictionaryData(body)) as { code?: number; msg?: string; data?: unknown } if (r.code !== 200 && r.code !== undefined) { - log.error(`dict dataUpdate 失败 (code=${r.code}): ${r.msg}`) + const enhanced = enhanceFromBackend(r.msg || '', 'dictData', { entity: 'dict' }) + log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`) if (opts.json) printJson(r) process.exit(1) }