Skip to content

Commit

Permalink
Issue #000 fix: add log for error case
Browse files Browse the repository at this point in the history
  • Loading branch information
Harishkumar Gangula committed Dec 26, 2018
1 parent 25b37c5 commit ce301ec
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/service/telemetry-service.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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') {
Expand All @@ -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) {
Expand Down

0 comments on commit ce301ec

Please sign in to comment.