forked from NoeFabris/opencode-antigravity-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.ts
More file actions
54 lines (50 loc) · 1.43 KB
/
Copy patherrors.ts
File metadata and controls
54 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Custom error types for opencode-antigravity-auth plugin.
*
* Ported from LLM-API-Key-Proxy for robust error handling.
*/
/**
* Error thrown when Antigravity returns an empty response after retry attempts.
*
* Empty responses can occur when:
* - The model has no candidates/choices
* - The response body is empty or malformed
* - A temporary service issue prevents generation
*/
export class EmptyResponseError extends Error {
readonly provider: string;
readonly model: string;
readonly attempts: number;
constructor(
provider: string,
model: string,
attempts: number,
message?: string,
) {
super(
message ??
`The model returned an empty response after ${attempts} attempts. ` +
`This may indicate a temporary service issue. Please try again.`,
);
this.name = "EmptyResponseError";
this.provider = provider;
this.model = model;
this.attempts = attempts;
}
}
/**
* Error thrown when tool ID matching fails and cannot be recovered.
*/
export class ToolIdMismatchError extends Error {
readonly expectedIds: string[];
readonly foundIds: string[];
constructor(expectedIds: string[], foundIds: string[], message?: string) {
super(
message ??
`Tool ID mismatch: expected [${expectedIds.join(", ")}] but found [${foundIds.join(", ")}]`,
);
this.name = "ToolIdMismatchError";
this.expectedIds = expectedIds;
this.foundIds = foundIds;
}
}