forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors-jEgvFRKI.d.cts
More file actions
69 lines (68 loc) · 2.55 KB
/
Copy patherrors-jEgvFRKI.d.cts
File metadata and controls
69 lines (68 loc) · 2.55 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
interface LilyRequestMetadata {
method: string;
path: string;
url: string;
}
interface LilyErrorOptions {
code?: string;
statusCode?: number;
details?: unknown;
cause?: unknown;
request?: LilyRequestMetadata;
/** Redacted excerpt of the response body, safe to log or send to a bug tracker. */
bodySnippet?: string;
/** Delta-seconds value from a Retry-After header, when present. */
retryAfterSeconds?: number;
}
declare const LILY_ERROR_CODES: Readonly<{
CONFIG_ERROR: "CONFIG_ERROR";
API_ERROR: "API_ERROR";
AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR";
AUTHORIZATION_ERROR: "AUTHORIZATION_ERROR";
VALIDATION_ERROR: "VALIDATION_ERROR";
TRANSPORT_ERROR: "TRANSPORT_ERROR";
NOT_FOUND: "NOT_FOUND";
CONFLICT: "CONFLICT";
RATE_LIMITED: "RATE_LIMITED";
SERVER_ERROR: "SERVER_ERROR";
TIMEOUT: "TIMEOUT";
}>;
type LilyErrorCode = keyof typeof LILY_ERROR_CODES;
declare class LilySdkError extends Error {
readonly code: string | undefined;
readonly statusCode: number | undefined;
readonly details: unknown;
readonly request: LilyRequestMetadata | undefined;
constructor(message: string, options?: LilyErrorOptions);
toJSON(): Record<string, unknown>;
toString(): string;
}
declare class LilyConfigError extends LilySdkError {
}
declare class LilyTransportError extends LilySdkError {
}
declare class LilyAuthenticationError extends LilySdkError {
}
/**
* Any non-ok HTTP response. The subclasses below narrow it, so
* `catch (e) { if (e instanceof LilyApiError) ... }` keeps working for callers
* that only care that the API rejected the request.
*/
declare class LilyApiError extends LilySdkError {
}
declare class LilyValidationError extends LilySdkError {
}
declare class LilyAuthorizationError extends LilyAuthenticationError {
}
declare class LilyNotFoundError extends LilyApiError {
}
declare class LilyConflictError extends LilyApiError {
}
declare class LilyServerError extends LilyApiError {
}
declare class LilyRateLimitError extends LilyApiError {
readonly retryAfterSeconds: number | undefined;
constructor(message: string, options?: LilyErrorOptions);
}
declare function isLilySdkError(value: unknown): value is LilySdkError;
export { LILY_ERROR_CODES as L, LilyApiError as a, LilyAuthenticationError as b, LilyAuthorizationError as c, LilyConfigError as d, LilyConflictError as e, type LilyErrorCode as f, LilyNotFoundError as g, LilyRateLimitError as h, LilySdkError as i, LilyServerError as j, LilyTransportError as k, LilyValidationError as l, isLilySdkError as m };