From ce301ec5c18f8e623892039e7f10808893d102d0 Mon Sep 17 00:00:00 2001 From: Harishkumar Gangula Date: Wed, 26 Dec 2018 15:30:17 +0530 Subject: [PATCH] Issue #000 fix: add log for error case --- src/service/telemetry-service.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/service/telemetry-service.js b/src/service/telemetry-service.js index 8f1c566..1d7fdab 100644 --- a/src/service/telemetry-service.js +++ b/src/service/telemetry-service.js @@ -1,7 +1,7 @@ const uuidv1 = require('uuid/v1'), request = require('request'), DispatcherClass = require('../dispatcher/dispatcher').Dispatcher; - config = require('../envVariables') +config = require('../envVariables') // TODO: Make this efficient. Implementation to be similar to typesafe config. Right now one configuration holds // together all supported transport configurations @@ -37,15 +37,15 @@ class TelemetryService { request.post(options, this.getRequestCallBack(req, res)); } } else { - this.sendError(res, { id: 'api.telemetry', params: { err: 'Configuration error' }}); + this.sendError(res, { id: 'api.telemetry', params: { err: 'Configuration error' } }); } } health(req, res) { if (this.config.localStorageEnabled === 'true') { this.dispatcher.health((healthy) => { - if (healthy) + if (healthy) this.sendSuccess(res, { id: 'api.health' }); - else + else this.sendError(res, { id: 'api.health', params: { err: 'Telemetry API is unhealthy' } }); }) } else if (this.config.telemetryProxyEnabled === 'true') { @@ -56,8 +56,12 @@ class TelemetryService { } getRequestCallBack(req, res) { return (err, data) => { - if (err) this.sendError(res, { id: 'api.telemetry', params: { err: err } }); - else this.sendSuccess(res, { id: 'api.telemetry' }); + if (err) { + this.sendError(res, { id: 'api.telemetry', params: { err: err } }); + } + else { + this.sendSuccess(res, { id: 'api.telemetry' }); + } } } sendError(res, options) {