netlify 10.1.2 → 11.0.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.
- package/package.json +4 -4
- package/src/methods/response.js +10 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify",
|
|
3
3
|
"description": "Netlify Node.js API client",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "11.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"src/**/*.js",
|
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
"@netlify/open-api": "^2.8.0",
|
|
56
56
|
"lodash.camelcase": "^4.3.0",
|
|
57
57
|
"micro-api-client": "^3.3.0",
|
|
58
|
-
"node-fetch": "^
|
|
58
|
+
"node-fetch": "^3.0.0",
|
|
59
59
|
"omit.js": "^2.0.2",
|
|
60
|
-
"p-wait-for": "^
|
|
60
|
+
"p-wait-for": "^4.0.0",
|
|
61
61
|
"qs": "^6.9.6"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@netlify/eslint-config-node": "^
|
|
64
|
+
"@netlify/eslint-config-node": "^5.1.4",
|
|
65
65
|
"ava": "^3.0.0",
|
|
66
66
|
"c8": "^7.11.0",
|
|
67
67
|
"from2-string": "^1.1.0",
|
package/src/methods/response.js
CHANGED
|
@@ -10,7 +10,7 @@ export const parseResponse = async function (response) {
|
|
|
10
10
|
|
|
11
11
|
if (!response.ok) {
|
|
12
12
|
const ErrorType = responseType === 'json' ? JSONHTTPError : TextHTTPError
|
|
13
|
-
throw new ErrorType(response, parsedResponse)
|
|
13
|
+
throw addFallbackErrorMessage(new ErrorType(response, parsedResponse), textResponse)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
return parsedResponse
|
|
@@ -34,13 +34,20 @@ const parseJsonResponse = function (response, textResponse, responseType) {
|
|
|
34
34
|
try {
|
|
35
35
|
return JSON.parse(textResponse)
|
|
36
36
|
} catch {
|
|
37
|
-
throw new TextHTTPError(response, textResponse)
|
|
37
|
+
throw addFallbackErrorMessage(new TextHTTPError(response, textResponse), textResponse)
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
const addFallbackErrorMessage = function (error, textResponse) {
|
|
42
|
+
error.message = error.message || textResponse
|
|
43
|
+
return error
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
export const getFetchError = function (error, url, opts) {
|
|
42
47
|
const data = omit.default(opts, ['Authorization'])
|
|
43
|
-
error.name
|
|
48
|
+
if (error.name !== 'FetchError') {
|
|
49
|
+
error.name = 'FetchError'
|
|
50
|
+
}
|
|
44
51
|
error.url = url
|
|
45
52
|
error.data = data
|
|
46
53
|
return error
|