@agility/management-sdk 0.1.38 → 0.1.39

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,4 +1,8 @@
1
1
  export declare class Exception extends Error {
2
2
  constructor(message: string, inner?: Error);
3
3
  innerError?: Error;
4
+ /** HTTP status code from the underlying response, when available. */
5
+ statusCode?: number;
6
+ /** Raw response body from the underlying response, when available. */
7
+ responseData?: unknown;
4
8
  }
@@ -19,8 +19,24 @@ exports.Exception = void 0;
19
19
  var Exception = /** @class */ (function (_super) {
20
20
  __extends(Exception, _super);
21
21
  function Exception(message, inner) {
22
- var _this = _super.call(this, message) || this;
22
+ var _this = this;
23
+ var _a, _b, _c, _d;
24
+ var anyErr = inner;
25
+ var status = (_a = anyErr === null || anyErr === void 0 ? void 0 : anyErr.response) === null || _a === void 0 ? void 0 : _a.status;
26
+ var data = (_b = anyErr === null || anyErr === void 0 ? void 0 : anyErr.response) === null || _b === void 0 ? void 0 : _b.data;
27
+ var detail = data
28
+ ? (typeof data === "string"
29
+ ? data
30
+ : ((_d = (_c = data.exceptionMessage) !== null && _c !== void 0 ? _c : data.message) !== null && _d !== void 0 ? _d : JSON.stringify(data)))
31
+ : anyErr === null || anyErr === void 0 ? void 0 : anyErr.message;
32
+ // Surface the server's status + response body in the message. The Management API
33
+ // (and other callers) only read Error.message, so folding the response detail in here
34
+ // turns an opaque "Unable to save the container" into
35
+ // "Unable to save the container (HTTP 500): <server message>".
36
+ _this = _super.call(this, detail ? "".concat(message).concat(status ? " (HTTP ".concat(status, ")") : "", ": ").concat(detail) : message) || this;
23
37
  _this.innerError = inner;
38
+ _this.statusCode = status;
39
+ _this.responseData = data;
24
40
  return _this;
25
41
  }
26
42
  return Exception;