forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
88 lines (87 loc) · 2.61 KB
/
Copy patherrors.js
File metadata and controls
88 lines (87 loc) · 2.61 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// src/errors/sdk-error.ts
var LILY_ERROR_CODES = Object.freeze({
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"
});
var LilySdkError = class _LilySdkError extends Error {
code;
statusCode;
details;
request;
constructor(message, options = {}) {
super(message, { cause: options.cause });
this.name = new.target.name;
this.code = options.code;
this.statusCode = options.statusCode;
this.details = options.details;
this.request = options.request;
}
toJSON() {
const result = {
name: this.name,
message: this.message
};
if (this.code !== void 0) {
result.code = this.code;
}
if (this.statusCode !== void 0) {
result.statusCode = this.statusCode;
}
if (this.details !== void 0) {
result.details = this.details;
}
if (this.request !== void 0) {
result.request = this.request;
}
const cause = this.cause;
if (cause !== void 0 && cause !== null) {
result.cause = cause instanceof _LilySdkError ? cause.toJSON() : cause instanceof Error ? { name: cause.name, message: cause.message } : cause;
}
return result;
}
toString() {
const parts = [this.name, this.message];
if (this.code !== void 0) {
parts.push(`[${this.code}]`);
}
if (this.statusCode !== void 0) {
parts.push(`(HTTP ${this.statusCode})`);
}
return parts.join(": ");
}
};
var LilyConfigError = class extends LilySdkError {
};
var LilyTransportError = class extends LilySdkError {
};
var LilyAuthenticationError = class extends LilySdkError {
};
var LilyApiError = class extends LilySdkError {
};
var LilyAuthorizationError = class extends LilyAuthenticationError {
};
var LilyNotFoundError = class extends LilyApiError {
};
var LilyConflictError = class extends LilyApiError {
};
var LilyServerError = class extends LilyApiError {
};
var LilyRateLimitError = class extends LilyApiError {
retryAfterSeconds;
constructor(message, options = {}) {
super(message, options);
this.retryAfterSeconds = options.retryAfterSeconds;
}
};
export { LILY_ERROR_CODES, LilyApiError, LilyAuthenticationError, LilyAuthorizationError, LilyConfigError, LilyConflictError, LilyNotFoundError, LilyRateLimitError, LilySdkError, LilyServerError, LilyTransportError };
//# sourceMappingURL=errors.js.map
//# sourceMappingURL=errors.js.map