aboutsummaryrefslogtreecommitdiff
path: root/src/cdp/errors.ts
blob: cf1dab7aefe89efdfa33528104c239d8b05cac6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export type CdpErrorKind =
  | "transport_closed"
  | "timeout"
  | "session_not_found"
  | "remote_error"
  | "discovery_failed"
  | "invalid_response";

export type CdpError = {
  readonly kind: CdpErrorKind;
  readonly message: string;
  readonly method?: string;
};

export const cdpError = (
  kind: CdpErrorKind,
  message: string,
  method?: string,
): CdpError => ({ kind, message, ...(method !== undefined ? { method } : {}) });