-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
errors.ts
29 lines (24 loc) · 934 Bytes
/
errors.ts
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
export class EOFError extends Error {}
export class ConnectionClosedError extends Error {}
export class SubscriptionClosedError extends Error {}
export class ErrorReplyError extends Error {}
export class NotImplementedError extends Error {
constructor(message?: string) {
super(message ? `Not implemented: ${message}` : "Not implemented");
}
}
export class InvalidStateError extends Error {
constructor(message?: string) {
const base = "Invalid state";
super(message ? `${base}: ${message}` : base);
}
}
export function isRetriableError(error: unknown): boolean {
return (error instanceof Deno.errors.BadResource ||
error instanceof Deno.errors.BrokenPipe ||
error instanceof Deno.errors.ConnectionAborted ||
error instanceof Deno.errors.ConnectionRefused ||
error instanceof Deno.errors.ConnectionReset ||
error instanceof Deno.errors.UnexpectedEof ||
error instanceof EOFError);
}