返回 DeepSeek-Reasonix
errors.ts
根目录 / desktop / electron / src / main / browser / errors.ts
1 import { RpcError } from "../rpc.js";
2
3 // Codes the Go BrowserExecutor maps onto its kernel sentinels; anything else
4 // is a transport failure and therefore an unknown outcome for a reserved write.
5 export const BROWSER_ERR_STALE_REFERENCE = -32010;
6 export const BROWSER_ERR_TAKEN_OVER = -32011;
7 export const BROWSER_ERR_NO_GRANT = -32012;
8
9 export type BrowserFailureKind = "page_not_ready" | "script_runtime_error" | "surface_unavailable" | "invalid_image" | "stale_document" | "capability_unsupported" | "cancelled";
10
11 export function browserFailure(kind: BrowserFailureKind, detail: string): RpcError {
12 return new RpcError(-32013, `${kind}: ${detail}`, { kind });
13 }
14
15 export function staleReference(detail: string): RpcError {
16 return new RpcError(BROWSER_ERR_STALE_REFERENCE, `stale reference: ${detail}`, { kind: "stale_document" });
17 }
18
19 export function takenOver(detail: string): RpcError {
20 return new RpcError(BROWSER_ERR_TAKEN_OVER, `tab taken over by the user: ${detail}`, { kind: "taken_over" });
21 }
22
23 export function noGrant(detail: string): RpcError {
24 return new RpcError(BROWSER_ERR_NO_GRANT, `no browser grant: ${detail}`);
25 }
26
26 lines TYPESCRIPT