@vulog/aima-client 1.0.10 → 1.0.11
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/README.md +4 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +12 -6
- package/dist/index.mjs +13 -7
- package/package.json +1 -1
- package/src/getClient.ts +13 -7
- package/src/types.ts +3 -2
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -115,13 +115,19 @@ var CurlHelper = class {
|
|
|
115
115
|
// src/getClient.ts
|
|
116
116
|
var clientCache = new import_lru_cache.LRUCache({ max: 100 });
|
|
117
117
|
var formatError = (error) => {
|
|
118
|
-
|
|
118
|
+
if (error instanceof import_axios.AxiosError) {
|
|
119
|
+
return {
|
|
120
|
+
originalError: error.toJSON(),
|
|
121
|
+
formattedError: {
|
|
122
|
+
status: error.response?.status ?? error.status,
|
|
123
|
+
data: error.response?.data,
|
|
124
|
+
message: error.message
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
119
128
|
return {
|
|
120
|
-
formattedError: {
|
|
121
|
-
|
|
122
|
-
data
|
|
123
|
-
},
|
|
124
|
-
originalError: error.toJSON ? error.toJSON() : error
|
|
129
|
+
formattedError: {},
|
|
130
|
+
originalError: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)))
|
|
125
131
|
};
|
|
126
132
|
};
|
|
127
133
|
var getClient = (options) => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/getClient.ts
|
|
2
|
-
import axios from "axios";
|
|
2
|
+
import axios, { AxiosError } from "axios";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
import { LRUCache } from "lru-cache";
|
|
5
5
|
|
|
@@ -79,13 +79,19 @@ var CurlHelper = class {
|
|
|
79
79
|
// src/getClient.ts
|
|
80
80
|
var clientCache = new LRUCache({ max: 100 });
|
|
81
81
|
var formatError = (error) => {
|
|
82
|
-
|
|
82
|
+
if (error instanceof AxiosError) {
|
|
83
|
+
return {
|
|
84
|
+
originalError: error.toJSON(),
|
|
85
|
+
formattedError: {
|
|
86
|
+
status: error.response?.status ?? error.status,
|
|
87
|
+
data: error.response?.data,
|
|
88
|
+
message: error.message
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
83
92
|
return {
|
|
84
|
-
formattedError: {
|
|
85
|
-
|
|
86
|
-
data
|
|
87
|
-
},
|
|
88
|
-
originalError: error.toJSON ? error.toJSON() : error
|
|
93
|
+
formattedError: {},
|
|
94
|
+
originalError: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)))
|
|
89
95
|
};
|
|
90
96
|
};
|
|
91
97
|
var getClient = (options) => {
|
package/package.json
CHANGED
package/src/getClient.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
1
|
+
import axios, { AxiosError } from 'axios';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import { LRUCache } from 'lru-cache';
|
|
4
4
|
|
|
@@ -14,14 +14,20 @@ const clientCache = new LRUCache<
|
|
|
14
14
|
>({ max: 100 });
|
|
15
15
|
|
|
16
16
|
const formatError = (error: any): ClientError => {
|
|
17
|
-
|
|
17
|
+
if (error instanceof AxiosError) {
|
|
18
|
+
return {
|
|
19
|
+
originalError: error.toJSON(),
|
|
20
|
+
formattedError: {
|
|
21
|
+
status: error.response?.status ?? error.status,
|
|
22
|
+
data: error.response?.data,
|
|
23
|
+
message: error.message,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
return {
|
|
20
|
-
formattedError: {
|
|
21
|
-
|
|
22
|
-
data,
|
|
23
|
-
},
|
|
24
|
-
originalError: error.toJSON ? error.toJSON() : error,
|
|
29
|
+
formattedError: {},
|
|
30
|
+
originalError: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error))),
|
|
25
31
|
};
|
|
26
32
|
};
|
|
27
33
|
|