mcpscraper-sdk 0.23.0 → 0.23.1
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/index.cjs +16 -3
- package/dist/index.js +16 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38,16 +38,29 @@ function readString(body, key) {
|
|
|
38
38
|
}
|
|
39
39
|
return void 0;
|
|
40
40
|
}
|
|
41
|
+
var PUBLIC_SERVICE_UNAVAILABLE_MESSAGE = "This operation is temporarily unavailable. Please retry later.";
|
|
42
|
+
function publicErrorBody(status, body) {
|
|
43
|
+
if (status < 500) return body;
|
|
44
|
+
return {
|
|
45
|
+
error: "service_unavailable",
|
|
46
|
+
error_code: "service_unavailable",
|
|
47
|
+
error_type: "service_unavailable",
|
|
48
|
+
retryable: true,
|
|
49
|
+
status,
|
|
50
|
+
message: PUBLIC_SERVICE_UNAVAILABLE_MESSAGE
|
|
51
|
+
};
|
|
52
|
+
}
|
|
41
53
|
var ScraperApiError = class extends Error {
|
|
42
54
|
status;
|
|
43
55
|
code;
|
|
44
56
|
body;
|
|
45
57
|
constructor(status, body) {
|
|
46
|
-
|
|
58
|
+
const safeBody = publicErrorBody(status, body);
|
|
59
|
+
super(readString(safeBody, "message") ?? `mcpscraper.dev API request failed with status ${status}`);
|
|
47
60
|
this.name = "ScraperApiError";
|
|
48
61
|
this.status = status;
|
|
49
|
-
this.code = readString(
|
|
50
|
-
this.body =
|
|
62
|
+
this.code = readString(safeBody, "error_code") ?? readString(safeBody, "error");
|
|
63
|
+
this.body = safeBody;
|
|
51
64
|
}
|
|
52
65
|
isInsufficientBalance() {
|
|
53
66
|
return this.code === "insufficient_balance";
|
package/dist/index.js
CHANGED
|
@@ -6,16 +6,29 @@ function readString(body, key) {
|
|
|
6
6
|
}
|
|
7
7
|
return void 0;
|
|
8
8
|
}
|
|
9
|
+
var PUBLIC_SERVICE_UNAVAILABLE_MESSAGE = "This operation is temporarily unavailable. Please retry later.";
|
|
10
|
+
function publicErrorBody(status, body) {
|
|
11
|
+
if (status < 500) return body;
|
|
12
|
+
return {
|
|
13
|
+
error: "service_unavailable",
|
|
14
|
+
error_code: "service_unavailable",
|
|
15
|
+
error_type: "service_unavailable",
|
|
16
|
+
retryable: true,
|
|
17
|
+
status,
|
|
18
|
+
message: PUBLIC_SERVICE_UNAVAILABLE_MESSAGE
|
|
19
|
+
};
|
|
20
|
+
}
|
|
9
21
|
var ScraperApiError = class extends Error {
|
|
10
22
|
status;
|
|
11
23
|
code;
|
|
12
24
|
body;
|
|
13
25
|
constructor(status, body) {
|
|
14
|
-
|
|
26
|
+
const safeBody = publicErrorBody(status, body);
|
|
27
|
+
super(readString(safeBody, "message") ?? `mcpscraper.dev API request failed with status ${status}`);
|
|
15
28
|
this.name = "ScraperApiError";
|
|
16
29
|
this.status = status;
|
|
17
|
-
this.code = readString(
|
|
18
|
-
this.body =
|
|
30
|
+
this.code = readString(safeBody, "error_code") ?? readString(safeBody, "error");
|
|
31
|
+
this.body = safeBody;
|
|
19
32
|
}
|
|
20
33
|
isInsufficientBalance() {
|
|
21
34
|
return this.code === "insufficient_balance";
|