@databallr/sdk 0.3.2 → 0.3.3
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.
- package/dist/errors.d.ts +1 -2
- package/dist/errors.js +1 -5
- package/package.json +1 -1
package/dist/errors.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ interface DataballrErrorFields {
|
|
|
3
3
|
/**
|
|
4
4
|
* The shared envelope's `error` in UPPER_SNAKE (`INVALID_TOKEN`,
|
|
5
5
|
* `INSUFFICIENT_SCOPE`, `RATE_LIMITED`, ...), or `HTTP_ERROR` when the body
|
|
6
|
-
* is not that envelope.
|
|
7
|
-
* same.
|
|
6
|
+
* is not that envelope.
|
|
8
7
|
*/
|
|
9
8
|
readonly code: string;
|
|
10
9
|
/** The envelope's `type` (`validation`, `rate_limited`, `unavailable`, ...), when the API sends one. */
|
package/dist/errors.js
CHANGED
|
@@ -19,7 +19,7 @@ export function errorFromResponse(response, text) {
|
|
|
19
19
|
}
|
|
20
20
|
catch { }
|
|
21
21
|
const envelope = isEnvelope(body) ? body : undefined;
|
|
22
|
-
const code = envelope ?
|
|
22
|
+
const code = envelope ? envelope.error : "HTTP_ERROR";
|
|
23
23
|
return new DataballrError(stringOrUndefined(envelope?.message) ??
|
|
24
24
|
(envelope ? code : `Request failed with status ${response.status}`), {
|
|
25
25
|
status: response.status,
|
|
@@ -32,10 +32,6 @@ export function errorFromResponse(response, text) {
|
|
|
32
32
|
body,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
const LOWER_SNAKE_RE = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
|
|
36
|
-
function wireCode(error) {
|
|
37
|
-
return LOWER_SNAKE_RE.test(error) ? error.toUpperCase() : error;
|
|
38
|
-
}
|
|
39
35
|
function secondsFromRetryAfter(header) {
|
|
40
36
|
if (header === null)
|
|
41
37
|
return undefined;
|