Files
tyx_AI_xhs/apps/api/src/generation-submission-errors.ts
T

31 lines
1.3 KiB
TypeScript

export type GenerationSubmissionErrorCode =
| "generation_blocked"
| "generation_idempotency_conflict"
| "generation_not_found"
| "generation_request_invalid"
| "generation_storage_unavailable"
| "model_config_stale"
| "reference_invalid";
export class GenerationSubmissionError extends Error {
readonly code: GenerationSubmissionErrorCode;
readonly errorCategory: "gateway_balance_insufficient" | "gateway_contract_invalid" | "model_disabled" | "reference_invalid" | undefined;
readonly latest: { configVersion: number; creditCost: number; modelId: string } | undefined;
readonly storage: { capacityStatus: "normal" | "warning" | "critical" | "full" | "unavailable"; remainingBytes: number } | undefined;
constructor(
code: GenerationSubmissionErrorCode,
options: {
errorCategory?: "gateway_balance_insufficient" | "gateway_contract_invalid" | "model_disabled" | "reference_invalid";
latest?: { configVersion: number; creditCost: number; modelId: string };
storage?: { capacityStatus: "normal" | "warning" | "critical" | "full" | "unavailable"; remainingBytes: number };
} = {},
) {
super(code);
this.code = code;
this.errorCategory = options.errorCategory;
this.latest = options.latest;
this.storage = options.storage;
}
}