Skip to content

Commit 63452f8

Browse files
microsoftlyStevenic
authored andcommitted
update missing service url/address error message to be more detailed (#4061)
1 parent 14b4e39 commit 63452f8

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Node/core/src/bots/ChatConnector.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,22 @@ export class ChatConnector implements IConnector, IBotStorage {
272272
try {
273273
if (msg.type == 'delay') {
274274
setTimeout(cb, (<any>msg).value);
275-
} else if (msg.address && (<IChatConnectorAddress>msg.address).serviceUrl) {
276-
this.postMessage(msg, (idx == messages.length - 1), (err, address) => {
277-
addresses.push(address);
278-
cb(err);
279-
});
280275
} else {
281-
logger.error('ChatConnector: send - message is missing address or serviceUrl.')
282-
cb(new Error('Message missing address or serviceUrl.'));
276+
const addressExists = !!msg.address;
277+
const serviceUrlExists = addressExists && !!(<IChatConnectorAddress>msg.address).serviceUrl;
278+
279+
// checking for address exists is redundant here, its part of the def of serviceUrlExists
280+
if(serviceUrlExists) {
281+
this.postMessage(msg, (idx == messages.length - 1), (err, address) => {
282+
addresses.push(address);
283+
cb(err);
284+
});
285+
} else {
286+
const msg = `Message is missing ${addressExists ? 'address and serviceUrl' : 'serviceUrl'} `;
287+
288+
logger.error(`ChatConnector: send - ${msg}`)
289+
cb(new Error(msg));
290+
}
283291
}
284292
} catch (e) {
285293
cb(e);

0 commit comments

Comments
 (0)