@xsai/shared 0.4.0-beta.1 → 0.4.0-beta.2
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.d.ts +1 -1
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class XSAIError extends Error {
|
|
2
2
|
response;
|
|
3
|
-
constructor(message, response) {
|
|
4
|
-
super(message);
|
|
3
|
+
constructor(message, response, cause) {
|
|
4
|
+
super(message, { cause });
|
|
5
5
|
this.name = "XSAIError";
|
|
6
6
|
this.response = response;
|
|
7
7
|
}
|
|
@@ -43,14 +43,14 @@ const responseCatch = async (res) => {
|
|
|
43
43
|
return res;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const responseJSON = async (res) =>
|
|
47
|
-
const text = await
|
|
46
|
+
const responseJSON = async (res) => {
|
|
47
|
+
const text = await res.text();
|
|
48
48
|
try {
|
|
49
49
|
return JSON.parse(text);
|
|
50
|
-
} catch {
|
|
51
|
-
throw new
|
|
50
|
+
} catch (cause) {
|
|
51
|
+
throw new XSAIError(`Failed to parse response, response body: ${text}`, res, cause);
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
};
|
|
54
54
|
|
|
55
55
|
const trampoline = async (fn) => {
|
|
56
56
|
let result = await fn();
|