@cloudant/couchbackup 2.11.1-SNAPSHOT-264 → 2.11.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/includes/request.js +10 -16
- package/package.json +1 -1
package/includes/request.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright © 2017,
|
|
1
|
+
// Copyright © 2017, 2024 IBM Corp. All rights reserved.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -37,30 +37,24 @@ function errorHelper(err) {
|
|
|
37
37
|
}
|
|
38
38
|
debug('Applying response error message with status, url, and method');
|
|
39
39
|
// Override the status text with an improved message
|
|
40
|
-
let errorMsg = `${err.response.status} ${
|
|
41
|
-
`${method} ${requestUrl}`;
|
|
40
|
+
let errorMsg = `${err.response.status} ${method} ${requestUrl}`;
|
|
42
41
|
if (err.response.data) {
|
|
43
42
|
debug('Found response data');
|
|
44
43
|
// Check if we have a JSON response and try to get the error/reason
|
|
45
44
|
if (err.response.headers['content-type'] === 'application/json') {
|
|
46
45
|
debug('Response data is JSON');
|
|
47
|
-
// Append the
|
|
48
|
-
if (err.response.data.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
errorMsg += ` - Error: ${err.response.data.error}`;
|
|
52
|
-
if (err.response.data.reason) {
|
|
53
|
-
debug('Augmenting error message with reason property');
|
|
54
|
-
errorMsg += `, Reason: ${err.response.data.reason}`;
|
|
55
|
-
}
|
|
46
|
+
// Append the 'errors' message if available
|
|
47
|
+
if (err.response.data.errors && err.response.data.errors.length > 0) {
|
|
48
|
+
const originalError = err.response.data.errors[0];
|
|
49
|
+
originalError.message = `${errorMsg} - Error: ${originalError.message}`;
|
|
56
50
|
}
|
|
57
51
|
} else {
|
|
58
52
|
errorMsg += err.response.data;
|
|
53
|
+
// Set a new message for use by the node-sdk-core
|
|
54
|
+
// We use the errors array because it gets processed
|
|
55
|
+
// ahead of all other service errors.
|
|
56
|
+
err.response.data.errors = [{ message: errorMsg }];
|
|
59
57
|
}
|
|
60
|
-
// Set a new message for use by the node-sdk-core
|
|
61
|
-
// We use the errors array because it gets processed
|
|
62
|
-
// ahead of all other service errors.
|
|
63
|
-
err.response.data.errors = [{ message: errorMsg }];
|
|
64
58
|
}
|
|
65
59
|
} else if (err.request) {
|
|
66
60
|
debug('Error did not include a response');
|
package/package.json
CHANGED