From 9ec9eb49c354c25ccfe34f46f31a2bcf8464aafa Mon Sep 17 00:00:00 2001 From: ssw Date: Sat, 27 Jun 2026 04:03:30 +0800 Subject: [PATCH] feat(print-info): v0.11e+ enhanceFromBackend (Phase C2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit print/info.ts: - import enhanceFromBackend + formatErrorLine - 后端 API 失败 + 数据为空 两种情况都用 enhanceFromBackend --- src/commands/print/info.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands/print/info.ts b/src/commands/print/info.ts index 66469bd..d7bf91c 100644 --- a/src/commands/print/info.ts +++ b/src/commands/print/info.ts @@ -7,6 +7,7 @@ import { Command } from 'commander' import { JnpfClient } from '../../core/client.ts' import { installAiHelpHook } from '../../core/help.ts' import { log, printJson } from '../../core/log.ts' +import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts' interface InfoOpts { id: string @@ -22,11 +23,13 @@ export function buildPrintInfoCommand(): Command { const c = await JnpfClient.fromToken() const r = await c.get>(`/system/printDev/${opts.id}`) if (r.code !== 200) { - log.error(`print info 失败 (code=${r.code}): ${r.msg}`) + const enhanced = enhanceFromBackend(r.msg || '', 'print', { entity: 'print' }) + log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`) process.exit(1) } if (!r.data) { - log.error(`print id=${opts.id} 不存在`) + const enhanced = enhanceFromBackend('打印模板 id 不存在', 'id', { entity: 'print' }) + log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`) process.exit(1) } if (opts.json) {