@sap-cloud-sdk/util 3.26.2-20250303014400.0 → 3.26.2
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/dist/error-with-cause.js
CHANGED
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ErrorWithCause = void 0;
|
|
4
4
|
exports.isErrorWithCause = isErrorWithCause;
|
|
5
5
|
const string_formatter_1 = require("./string-formatter");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
7
|
+
const logger = (0, logger_1.createLogger)({
|
|
8
|
+
package: 'util',
|
|
9
|
+
messageContext: 'error-with-cause'
|
|
10
|
+
});
|
|
6
11
|
/**
|
|
7
12
|
* Represents an error that was caused by another error.
|
|
8
13
|
*/
|
|
@@ -26,7 +31,16 @@ class ErrorWithCause extends Error {
|
|
|
26
31
|
addStack(cause) {
|
|
27
32
|
// Axios removed the stack property in version 0.27 which gave no useful information anyway. This adds the http cause.
|
|
28
33
|
if (this.isAxiosError(cause)) {
|
|
29
|
-
|
|
34
|
+
let response = '';
|
|
35
|
+
if (cause.response?.data) {
|
|
36
|
+
try {
|
|
37
|
+
response = `${string_formatter_1.unixEOL}${JSON.stringify(cause.response?.data, null, 2)}`;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
logger.warn(`Failed to stringify response data: ${error.message}`);
|
|
41
|
+
response = `${string_formatter_1.unixEOL}${cause.response?.data}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
30
44
|
this.stack = `${this.stack}${string_formatter_1.unixEOL}Caused by:${string_formatter_1.unixEOL}HTTP Response: ${cause.message}${response}`;
|
|
31
45
|
}
|
|
32
46
|
else if (this.stack && cause?.stack) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-with-cause.js","sourceRoot":"","sources":["../src/error-with-cause.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"error-with-cause.js","s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