优化
This commit is contained in:
@@ -693,7 +693,8 @@
|
||||
return String(error?.code || '') === 'A0409' || Number(error?.statusCode) === 409
|
||||
},
|
||||
remoteFailureMessage(error, fallback = '操作失败') {
|
||||
return formatApiError(error, fallback)
|
||||
console.error('[PDA picking] failed', { message: error?.message, code: error?.code, requestId: error?.requestId, traceId: error?.traceId })
|
||||
return formatApiError(error, fallback, false)
|
||||
},
|
||||
async refreshAfterTaskConflict(message) {
|
||||
const requestedTaskId = this.remoteTaskId || this.currentBox.taskId
|
||||
|
||||
@@ -266,9 +266,9 @@ test('picking mutations stay closed until the canonical task has been claimed',
|
||||
}
|
||||
})
|
||||
|
||||
test('completion shows a Chinese server failure with a request correlation id', () => {
|
||||
test('completion shows a concise Chinese failure and retains correlation ids in diagnostics', () => {
|
||||
assert.match(page, /remoteFailureMessage\(error, fallback = '操作失败'\)/)
|
||||
assert.match(page, /formatApiError\(error, fallback\)/)
|
||||
assert.match(page, /formatApiError\(error, fallback, false\)/)
|
||||
assert.match(page, /import \{ containerReference, formatApiError, sanitizeUserMessage \}/)
|
||||
assert.match(page, /requestIdFromServer: error\.requestId/)
|
||||
assert.match(page, /this\.remoteFailureMessage\(error, '装柜完成失败'\)/)
|
||||
|
||||
@@ -27,6 +27,9 @@ test('operator errors hide internal ids but retain request and trace evidence',
|
||||
assert.match(message, /错误码:S0500/)
|
||||
assert.match(message, /requestId:dbde0d81/)
|
||||
assert.match(message, /traceId:5b0ba4f3/)
|
||||
const concise = formatApiError(error, '任务处理失败', false)
|
||||
assert.doesNotMatch(concise, /错误码|requestId|traceId|S0500/)
|
||||
assert.match(concise, /处理失败/)
|
||||
assert.equal(sanitizeUserMessage('operation 2092889048731414530 failed'), 'operation 内部标识已隐藏 failed')
|
||||
})
|
||||
|
||||
|
||||
@@ -25,8 +25,9 @@ export function sanitizeUserMessage(message, fallback = '操作失败') {
|
||||
return sanitized || fallback
|
||||
}
|
||||
|
||||
export function formatApiError(error, fallback = '操作失败') {
|
||||
export function formatApiError(error, fallback = '操作失败', includeDiagnostics = true) {
|
||||
const message = sanitizeUserMessage(error?.message, fallback)
|
||||
if (!includeDiagnostics) return message
|
||||
const code = String(error?.code ?? '').trim()
|
||||
const requestId = String(error?.requestId ?? '').trim()
|
||||
const traceId = String(error?.traceId ?? '').trim()
|
||||
|
||||
Reference in New Issue
Block a user