Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private buildQueueResponse(response: HttpOperationResponse): QueueResponse {
try {
const queue = buildQueue(response.parsedBody);
const queueResponse: QueueResponse = Object.assign(queue || {}, { _response: response });
return queueResponse;
} catch (err) {
log.warning("Failure parsing response from service - %0 ", err);
throw new RestError(
`Error occurred while parsing the response body - cannot form a queue object using the response from the service.`,
RestError.PARSE_ERROR,
response.status,
stripRequest(response.request),
stripResponse(response)
);
}
}
private buildTopicResponse(response: HttpOperationResponse): TopicResponse {
try {
const topic = buildTopic(response.parsedBody);
const topicResponse: TopicResponse = Object.assign(topic || {}, { _response: response });
return topicResponse;
} catch (err) {
log.warning("Failure parsing response from service - %0 ", err);
throw new RestError(
`Error occurred while parsing the response body - cannot form a topic object using the response from the service.`,
RestError.PARSE_ERROR,
response.status,
stripRequest(response.request),
stripResponse(response)
);
}
}
for (let i = 0; i < rawTopicArray.length; i++) {
const topic = buildTopic(rawTopicArray[i]);
if (topic) {
topics.push(topic);
}
}
const listTopicsResponse: ListTopicsResponse = Object.assign(topics, { _response: response });
return listTopicsResponse;
} catch (err) {
log.warning("Failure parsing response from service - %0 ", err);
throw new RestError(
`Error occurred while parsing the response body - cannot form a list of topics using the response from the service.`,
RestError.PARSE_ERROR,
response.status,
stripRequest(response.request),
stripResponse(response)
);
}
}
private buildRuleResponse(response: HttpOperationResponse): RuleResponse {
try {
const rule = buildRule(response.parsedBody);
const ruleResponse: RuleResponse = Object.assign(rule || {}, { _response: response });
return ruleResponse;
} catch (err) {
log.warning("Failure parsing response from service - %0 ", err);
throw new RestError(
`Error occurred while parsing the response body - cannot form a rule object using the response from the service.`,
RestError.PARSE_ERROR,
response.status,
stripRequest(response.request),
stripResponse(response)
);
}
}
}
name: string,
serializer: AtomXmlSerializer
): Promise {
const webResource: WebResource = new WebResource(this.getUrl(name), "GET");
const response = await executeAtomXmlOperation(this, webResource, serializer);
if (
response.parsedBody == undefined ||
(Array.isArray(response.parsedBody) && response.parsedBody.length == 0)
) {
const err = new RestError(
`The messaging entity "${name}" being requested cannot be found.`,
"404",
404,
stripRequest(webResource),
stripResponse(response)
);
throw err;
}
return response;
}
private buildSubscriptionResponse(response: HttpOperationResponse): SubscriptionResponse {
try {
const subscription = buildSubscription(response.parsedBody);
const subscriptionResponse: SubscriptionResponse = Object.assign(subscription || {}, {
_response: response
});
return subscriptionResponse;
} catch (err) {
log.warning("Failure parsing response from service - %0 ", err);
throw new RestError(
`Error occurred while parsing the response body - cannot form a subscription object using the response from the service.`,
RestError.PARSE_ERROR,
response.status,
stripRequest(response.request),
stripResponse(response)
);
}
}
for (let i = 0; i < rawRuleArray.length; i++) {
const rule = buildRule(rawRuleArray[i]);
if (rule) {
rules.push(rule);
}
}
const listRulesResponse: ListRulesResponse = Object.assign(rules, { _response: response });
return listRulesResponse;
} catch (err) {
log.warning("Failure parsing response from service - %0 ", err);
throw new RestError(
`Error occurred while parsing the response body - cannot form a list of rules using the response from the service.`,
RestError.PARSE_ERROR,
response.status,
stripRequest(response.request),
stripResponse(response)
);
}
}