Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _isReceiverDisconnectedError(error: MessagingError | Error): boolean {
const partitionId = this._partitionContext.partitionId;
const withHostAndPartition = this._context.withHostAndPartition;
let result = false;
if (error) {
// condition is "amqp:link:stolen"
if (
(error as MessagingError).condition === ErrorNameConditionMapper.ReceiverDisconnectedError
) {
result = true;
} else if (error.message.match(/.*New receiver with higher epoch.*/i) !== null) {
result = true;
log.error(
withHostAndPartition(
partitionId,
"It looks like the error should have " +
"been a 'ReceiverDisconnectedError', however it was not translated correctly: %O."
),
error
);
}
}
return result;
}