fix: restore coding history and quota feedback
This commit is contained in:
25
electron/coding-runtime/pi/provider-failure.ts
Normal file
25
electron/coding-runtime/pi/provider-failure.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { CodingRuntimePublicError } from '../contracts';
|
||||
import { isAIGatewayUserContextMissing } from '../../../shared/ai-gateway-error-details';
|
||||
import { getAIGatewayErrorKind } from '../../../shared/ai-gateway-error-kind';
|
||||
|
||||
export function projectPiProviderFailure(message: unknown): CodingRuntimePublicError {
|
||||
if (typeof message === 'string' && isAIGatewayUserContextMissing(message)) {
|
||||
return {
|
||||
code: 'CODING_PROVIDER_AUTH_REQUIRED',
|
||||
message: '模型服务身份上下文无效,请重试;若仍失败请重新登录。',
|
||||
recoverable: true,
|
||||
};
|
||||
}
|
||||
if (typeof message === 'string' && getAIGatewayErrorKind(message) === 'quota_exhausted') {
|
||||
return {
|
||||
code: 'CODING_PROVIDER_QUOTA_EXHAUSTED',
|
||||
message: '词元点数余额不足,请充值后重试。',
|
||||
recoverable: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
code: 'CODING_RUNTIME_START_FAILED',
|
||||
message: '模型服务请求失败,请稍后重试。',
|
||||
recoverable: true,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user