From 63452f8df3adf6771daffcb983cea21984072907 Mon Sep 17 00:00:00 2001 From: Matthew Schwartz Date: Tue, 23 Jan 2018 14:36:15 -0800 Subject: [PATCH] update missing service url/address error message to be more detailed (#4061) --- Node/core/src/bots/ChatConnector.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Node/core/src/bots/ChatConnector.ts b/Node/core/src/bots/ChatConnector.ts index d84c81e3ef..f9a87faa3e 100644 --- a/Node/core/src/bots/ChatConnector.ts +++ b/Node/core/src/bots/ChatConnector.ts @@ -272,14 +272,22 @@ export class ChatConnector implements IConnector, IBotStorage { try { if (msg.type == 'delay') { setTimeout(cb, (msg).value); - } else if (msg.address && (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 && !!(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);