@zimmerstack/connect 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * What the API answered when it refused a request, or what stopped a request before it was sent.
3
+ *
4
+ * Branch on `code`: it is stable. `message` is written for a person (show it to them) and may change.
5
+ */
6
+ export class ZimmerStackError extends Error {
7
+ /** The HTTP status; 0 when the request never reached the API (see `code`). */
8
+ status;
9
+ /**
10
+ * The API's stable code (RATE_LIMITED, RATE_OUT_OF_BAND, SCOPE_MISSING, …), or one of this client's own:
11
+ * LIVE_KEY_IN_TEST, NETWORK_ERROR, TIMEOUT.
12
+ */
13
+ code;
14
+ /** What the API said about it: the offending fields of a VALIDATION, the budget of a RATE_LIMITED, … */
15
+ details;
16
+ /** Seconds until the same request can pass, when the API said so (429 and 503). */
17
+ retryAfterSeconds;
18
+ /** Which budget refused, on a RATE_LIMITED (writes, cells-hour, modifier-changes-day, …). */
19
+ scope;
20
+ /**
21
+ * true when the same request may pass later (a used-up budget, a fault on ZimmerStack's side, a
22
+ * network failure). The client has already retried what was worth holding a request open for;
23
+ * anything false is a verdict on the request itself: fix it, never resend it.
24
+ */
25
+ retryable;
26
+ /** The operation that failed, as the contract names it: "PUT /rates". Never contains the key. */
27
+ operation;
28
+ constructor(init) {
29
+ super(init.message, init.cause === undefined ? undefined : { cause: init.cause });
30
+ this.name = "ZimmerStackError";
31
+ this.status = init.status;
32
+ this.code = init.code;
33
+ this.details = init.details;
34
+ this.retryAfterSeconds = init.retryAfterSeconds;
35
+ this.scope = init.scope;
36
+ this.retryable = init.retryable;
37
+ this.operation = init.operation;
38
+ }
39
+ }
40
+ /** A mistake in how the client was set up or called. Nothing was sent. */
41
+ export class ZimmerStackUsageError extends Error {
42
+ constructor(message) {
43
+ super(message);
44
+ this.name = "ZimmerStackUsageError";
45
+ }
46
+ }