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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify",
3
3
  "description": "Netlify Node.js API client",
4
- "version": "10.1.2",
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": "^2.6.1",
58
+ "node-fetch": "^3.0.0",
59
59
  "omit.js": "^2.0.2",
60
- "p-wait-for": "^3.2.0",
60
+ "p-wait-for": "^4.0.0",
61
61
  "qs": "^6.9.6"
62
62
  },
63
63
  "devDependencies": {
64
- "@netlify/eslint-config-node": "^4.1.3",
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",
@@ -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 = 'FetchError'
48
+ if (error.name !== 'FetchError') {
49
+ error.name = 'FetchError'
50
+ }
44
51
  error.url = url
45
52
  error.data = data
46
53
  return error