UNPKG

channelape-sdk

Version:
24 lines 844 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ChannelApeError_1 = require("../model/ChannelApeError"); function generateApiError(url, response, body, expectedStatusCode) { let thisBody = body; if (thisBody === undefined) { thisBody = {}; } if (typeof thisBody === 'string') { thisBody = { body: thisBody, errors: [] }; } if (thisBody.errors === undefined) { thisBody.errors = []; } return new ChannelApeError_1.default(getErrorMessage(response, expectedStatusCode), response, url, thisBody.errors); } exports.default = generateApiError; function getErrorMessage(response, expectedStatusCode) { return `Expected Status ${expectedStatusCode} but got ${response.status}`; } //# sourceMappingURL=GenerateApiError.js.map