balena-request 11.5.2 → 11.5.3

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.
@@ -1,3 +1,16 @@
1
+ - commits:
2
+ - subject: Use response error as response message if there is one
3
+ hash: 909a8c6d89cebf7cc0f3a1ee90c70fd34e29e693
4
+ body: ""
5
+ footer:
6
+ Change-type: patch
7
+ change-type: patch
8
+ Signed-off-by: Matthew Yarmolinsky <matthew-timothy@balena.io>
9
+ signed-off-by: Matthew Yarmolinsky <matthew-timothy@balena.io>
10
+ author: Matthew Yarmolinsky
11
+ version: 11.5.3
12
+ title: "'Use response error as response message if there is one'"
13
+ date: 2022-04-05T16:15:33.596Z
1
14
  - commits:
2
15
  - subject: Drop circle.yml
3
16
  hash: d4fdd033595829116f90813ee2b65b5a3dd38df1
@@ -10,7 +23,7 @@
10
23
  author: Thodoris Greasidis
11
24
  version: 11.5.2
12
25
  title: "'Drop circle.yml'"
13
- date: 2022-04-04T13:22:18.188Z
26
+ date: 2022-04-04T13:14:27.546Z
14
27
  - commits:
15
28
  - subject: Drop mochainon & bump karma
16
29
  hash: c26d97fcb58971b2139c726306b92fd7593e1726
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
4
4
  automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
5
5
  This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ # v11.5.3
8
+ ## (2022-04-05)
9
+
10
+ * Use response error as response message if there is one [Matthew Yarmolinsky]
11
+
7
12
  # v11.5.2
8
13
  ## (2022-04-04)
9
14
 
package/build/utils.js CHANGED
@@ -115,6 +115,12 @@ function getErrorMessageFromResponse(response) {
115
115
  if (errorText != null) {
116
116
  return errorText;
117
117
  }
118
+ if (response.body != null && typeof response.body === 'object') {
119
+ const bodyMessageProp = ['message', 'error'].find((prop) => typeof response.body[prop] === 'string');
120
+ if (bodyMessageProp != null) {
121
+ response.body.message = response.body[bodyMessageProp];
122
+ }
123
+ }
118
124
  return response.body;
119
125
  }
120
126
  exports.getErrorMessageFromResponse = getErrorMessageFromResponse;
package/lib/utils.ts CHANGED
@@ -118,6 +118,15 @@ export function getErrorMessageFromResponse(response: BalenaRequestResponse) {
118
118
  return errorText;
119
119
  }
120
120
 
121
+ if (response.body != null && typeof response.body === 'object') {
122
+ const bodyMessageProp = ['message', 'error'].find(
123
+ (prop) => typeof response.body[prop] === 'string',
124
+ );
125
+ if (bodyMessageProp != null) {
126
+ response.body.message = response.body[bodyMessageProp];
127
+ }
128
+ }
129
+
121
130
  return response.body;
122
131
  }
123
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balena-request",
3
- "version": "11.5.2",
3
+ "version": "11.5.3",
4
4
  "description": "Balena HTTP client",
5
5
  "main": "build/request.js",
6
6
  "types": "build/request.d.ts",
@@ -71,6 +71,6 @@
71
71
  "balena-auth": "^4.0.0"
72
72
  },
73
73
  "versionist": {
74
- "publishedAt": "2022-04-04T13:22:18.304Z"
74
+ "publishedAt": "2022-04-05T16:15:33.718Z"
75
75
  }
76
76
  }