修复登录失败原因提示
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Successful in 5m18s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Successful in 5m26s
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Successful in 5m37s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Successful in 5m51s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m36s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m20s
Project CI / Repository checks (pull_request) Successful in 3m48s
Project CI / Frontend tests (pull_request) Successful in 5m2s
Project CI / Native shell tests (pull_request) Successful in 7m24s
Project CI / Backend tests (pull_request) Successful in 7m53s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m6s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Successful in 5m18s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Successful in 5m26s
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Successful in 5m37s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Successful in 5m51s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m36s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m20s
Project CI / Repository checks (pull_request) Successful in 3m48s
Project CI / Frontend tests (pull_request) Successful in 5m2s
Project CI / Native shell tests (pull_request) Successful in 7m24s
Project CI / Backend tests (pull_request) Successful in 7m53s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m6s
统一错误解析器支持字符串 error 响应 补充登录错误原因回归测试 同步认证排障记忆
This commit is contained in:
@@ -177,23 +177,34 @@ export function parseApiErrorMessage(rawText: string, fallbackMessage: string) {
|
||||
const parsed = JSON.parse(rawText) as
|
||||
| ApiErrorResponse
|
||||
| {
|
||||
error?: {
|
||||
message?: string;
|
||||
code?: string;
|
||||
details?: Record<string, unknown> | null;
|
||||
};
|
||||
error?:
|
||||
| string
|
||||
| {
|
||||
message?: string;
|
||||
code?: string;
|
||||
details?: Record<string, unknown> | null;
|
||||
};
|
||||
message?: string;
|
||||
code?: string;
|
||||
};
|
||||
|
||||
const detailMessage = readApiErrorDetailMessage(parsed.error?.details);
|
||||
const detailMessage =
|
||||
typeof parsed.error === 'object' && parsed.error !== null
|
||||
? readApiErrorDetailMessage(parsed.error.details)
|
||||
: '';
|
||||
|
||||
if (detailMessage) {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
if (typeof parsed.error === 'string' && parsed.error.trim()) {
|
||||
return parsed.error.trim();
|
||||
}
|
||||
|
||||
if (
|
||||
typeof parsed.error?.message === 'string' &&
|
||||
typeof parsed.error === 'object' &&
|
||||
parsed.error !== null &&
|
||||
typeof parsed.error.message === 'string' &&
|
||||
parsed.error.message.trim()
|
||||
) {
|
||||
return parsed.error.message.trim();
|
||||
@@ -209,7 +220,10 @@ export function parseApiErrorMessage(rawText: string, fallbackMessage: string) {
|
||||
}
|
||||
|
||||
const errorCode =
|
||||
typeof parsed.error?.code === 'string' && parsed.error.code.trim()
|
||||
typeof parsed.error === 'object' &&
|
||||
parsed.error !== null &&
|
||||
typeof parsed.error.code === 'string' &&
|
||||
parsed.error.code.trim()
|
||||
? parsed.error.code.trim()
|
||||
: 'code' in parsed &&
|
||||
typeof parsed.code === 'string' &&
|
||||
|
||||
Reference in New Issue
Block a user