feat(dongchedi): translate platform "server exception" into actionable copy
Map dongchedi adapter failures (raw "server exception" or dongchedi_platform_exception) to a Chinese prompt steering the user to the dongchedi backend, so renderer/admin views and desktop-task error payloads no longer surface the opaque platform message.
This commit is contained in:
@@ -2,6 +2,7 @@ import { createHash, createHmac } from 'node:crypto'
|
||||
|
||||
import type { JsonValue } from '@geo/shared-types'
|
||||
|
||||
import { DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE } from '../../shared/publisher-errors'
|
||||
import type { PublishAdapter, PublishAdapterContext } from './base'
|
||||
import {
|
||||
ensureViewLoaded,
|
||||
@@ -127,6 +128,10 @@ function isDongchediChallengeMessage(message: string): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
function isDongchediPlatformExceptionMessage(message: string): boolean {
|
||||
return /\bserver[\s_-]*exception\b/i.test(message)
|
||||
}
|
||||
|
||||
function redactDiagnosticText(value: string, maxLength = 220): string {
|
||||
return value
|
||||
.replace(
|
||||
@@ -1009,6 +1014,26 @@ function failureResult(
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(error instanceof DongchediAdapterError && error.code === 'dongchedi_platform_exception') ||
|
||||
isDongchediPlatformExceptionMessage(message)
|
||||
) {
|
||||
return {
|
||||
status: 'failed',
|
||||
summary: DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE,
|
||||
error: {
|
||||
code: 'dongchedi_platform_exception',
|
||||
message: DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE,
|
||||
detail:
|
||||
error instanceof DongchediAdapterError && error.detail
|
||||
? error.detail
|
||||
: {
|
||||
platform_message: message,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: 'failed',
|
||||
summary: '懂车帝发布失败。',
|
||||
@@ -1080,6 +1105,9 @@ export const dongchediAdapter: PublishAdapter = {
|
||||
taskId: context.taskId,
|
||||
...detail,
|
||||
})
|
||||
if (isDongchediPlatformExceptionMessage(message)) {
|
||||
throw new DongchediAdapterError('dongchedi_platform_exception', message, detail)
|
||||
}
|
||||
throw new DongchediAdapterError(
|
||||
'dongchedi_publish_failed',
|
||||
message || 'dongchedi_draft_failed',
|
||||
@@ -1115,6 +1143,9 @@ export const dongchediAdapter: PublishAdapter = {
|
||||
taskId: context.taskId,
|
||||
...detail,
|
||||
})
|
||||
if (isDongchediPlatformExceptionMessage(message)) {
|
||||
throw new DongchediAdapterError('dongchedi_platform_exception', message, detail)
|
||||
}
|
||||
throw new DongchediAdapterError(
|
||||
'dongchedi_publish_failed',
|
||||
message || 'dongchedi_publish_failed',
|
||||
|
||||
Reference in New Issue
Block a user