Skip to content

Commit

Permalink
update missing service url/address error message to be more detailed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
microsoftly authored and Stevenic committed Jan 23, 2018
1 parent 14b4e39 commit 63452f8
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Node/core/src/bots/ChatConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,22 @@ export class ChatConnector implements IConnector, IBotStorage {
try {
if (msg.type == 'delay') {
setTimeout(cb, (<any>msg).value);
} else if (msg.address && (<IChatConnectorAddress>msg.address).serviceUrl) {
this.postMessage(msg, (idx == messages.length - 1), (err, address) => {
addresses.push(address);
cb(err);
});
} else {
logger.error('ChatConnector: send - message is missing address or serviceUrl.')
cb(new Error('Message missing address or serviceUrl.'));
const addressExists = !!msg.address;
const serviceUrlExists = addressExists && !!(<IChatConnectorAddress>msg.address).serviceUrl;

// checking for address exists is redundant here, its part of the def of serviceUrlExists
if(serviceUrlExists) {
this.postMessage(msg, (idx == messages.length - 1), (err, address) => {
addresses.push(address);
cb(err);
});
} else {
const msg = `Message is missing ${addressExists ? 'address and serviceUrl' : 'serviceUrl'} `;

logger.error(`ChatConnector: send - ${msg}`)
cb(new Error(msg));
}
}
} catch (e) {
cb(e);
Expand Down

0 comments on commit 63452f8

Please sign in to comment.