@camunda8/sdk
Version:
[](https://www.npmjs.com/package/@camunda8/sdk)
48 lines • 1.94 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HTTPError = void 0;
const Got = __importStar(require("got"));
class HTTPError extends Got.HTTPError {
constructor(response) {
super(response);
try {
const details = JSON.parse(response?.body || '{}');
this.statusCode = details.status;
}
catch (e) {
this.statusCode = 0;
// Sometimes APIs return errors data in plain text (not JSON)
// and sometimes we get back an HTML error page (for example: 502 Bad Gateway)
// We want to extract and surface plain text errors
// and ignore the HTML strings
if (!(response.body ?? '<').startsWith('<')) {
this.message += ` - ${response.body}`;
}
}
}
}
exports.HTTPError = HTTPError;
//# sourceMappingURL=GotErrors.js.map