nylas 6.4.0 → 6.4.1
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/lib/nylas-connection.js +22 -28
- package/package.json +1 -1
package/lib/nylas-connection.js
CHANGED
|
@@ -193,30 +193,22 @@ var NylasConnection = /** @class */ (function () {
|
|
|
193
193
|
console.warn(warning);
|
|
194
194
|
}
|
|
195
195
|
if (response.status > 299) {
|
|
196
|
-
return response
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
return reject(error);
|
|
208
|
-
})
|
|
209
|
-
.catch(function () {
|
|
210
|
-
return response
|
|
211
|
-
.text()
|
|
212
|
-
.then(function (text) {
|
|
213
|
-
var error = new nylas_api_error_1.default(response.status, response.statusText, text);
|
|
196
|
+
return response.text().then(function (body) {
|
|
197
|
+
try {
|
|
198
|
+
var parsedApiError = JSON.parse(body);
|
|
199
|
+
var error = new nylas_api_error_1.default(response.status, parsedApiError.type, parsedApiError.message);
|
|
200
|
+
if (parsedApiError.missing_fields) {
|
|
201
|
+
error.missingFields = parsedApiError.missing_fields;
|
|
202
|
+
}
|
|
203
|
+
if (parsedApiError.server_error) {
|
|
204
|
+
error.serverError = parsedApiError.server_error;
|
|
205
|
+
}
|
|
214
206
|
return reject(error);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
var error = new nylas_api_error_1.default(response.status, response.statusText,
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
var error = new nylas_api_error_1.default(response.status, response.statusText, body);
|
|
218
210
|
return reject(error);
|
|
219
|
-
}
|
|
211
|
+
}
|
|
220
212
|
});
|
|
221
213
|
}
|
|
222
214
|
else {
|
|
@@ -244,12 +236,14 @@ var NylasConnection = /** @class */ (function () {
|
|
|
244
236
|
return resolve(response.text());
|
|
245
237
|
}
|
|
246
238
|
else {
|
|
247
|
-
return response
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
239
|
+
return response.text().then(function (text) {
|
|
240
|
+
try {
|
|
241
|
+
return resolve(JSON.parse(text));
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
return resolve(text);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
253
247
|
}
|
|
254
248
|
}
|
|
255
249
|
})
|