1
This commit is contained in:
@@ -18,6 +18,9 @@ export interface Match3DGeneratedBackgroundAsset {
|
||||
prompt: string;
|
||||
imageSrc?: string | null;
|
||||
imageObjectKey?: string | null;
|
||||
containerPrompt?: string | null;
|
||||
containerImageSrc?: string | null;
|
||||
containerImageObjectKey?: string | null;
|
||||
status: string;
|
||||
error?: string | null;
|
||||
}
|
||||
@@ -115,6 +118,7 @@ export interface PutMatch3DWorkRequest {
|
||||
export interface GenerateMatch3DWorkTagsRequest {
|
||||
gameName: string;
|
||||
themeText: string;
|
||||
summary?: string | null;
|
||||
}
|
||||
|
||||
export interface GenerateMatch3DWorkTagsResponse {
|
||||
|
||||
@@ -150,11 +150,21 @@ function readTrimmedMessage(value: unknown) {
|
||||
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
||||
}
|
||||
|
||||
function readApiErrorDetailMessage(details: unknown) {
|
||||
if (!isRecord(details)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 后端通用 message 常用于错误分类;details.message / details.reason
|
||||
// 才是给用户定位问题的业务原因,配置缺失类错误通常只带 reason。
|
||||
return (
|
||||
readTrimmedMessage(details.message) ||
|
||||
readTrimmedMessage(details.reason)
|
||||
);
|
||||
}
|
||||
|
||||
export function getApiErrorDisplayMessage(error: ApiErrorPayload) {
|
||||
// 后端通用 message 常用于错误分类,details.message 才是给用户定位问题的业务原因。
|
||||
const detailMessage = isRecord(error.details)
|
||||
? readTrimmedMessage(error.details.message)
|
||||
: '';
|
||||
const detailMessage = readApiErrorDetailMessage(error.details);
|
||||
|
||||
return detailMessage || readTrimmedMessage(error.message);
|
||||
}
|
||||
@@ -177,9 +187,7 @@ export function parseApiErrorMessage(rawText: string, fallbackMessage: string) {
|
||||
code?: string;
|
||||
};
|
||||
|
||||
const detailMessage = isRecord(parsed.error?.details)
|
||||
? readTrimmedMessage(parsed.error.details.message)
|
||||
: '';
|
||||
const detailMessage = readApiErrorDetailMessage(parsed.error?.details);
|
||||
|
||||
if (detailMessage) {
|
||||
return detailMessage;
|
||||
|
||||
Reference in New Issue
Block a user