Skip to content

Commit

Permalink
guard redis error handler (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nell Gawor authored and chambrid committed Sep 9, 2016
1 parent 26185b4 commit 590d1e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
21 changes: 12 additions & 9 deletions src/scripts/redis.delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ let currentResponse;

module.exports = (robot) => {

redis.on('error', function(err) {
if (currentResponse) {
let message = i18n.__('redis.error', err);
robot.emit('ibmcloud.formatter', {
response: currentResponse,
message: message
});
}
});
if (redis) {
redis.on('error', function(err) {
if (currentResponse) {
let message = i18n.__('redis.error', err);
robot.emit('ibmcloud.formatter', {
response: currentResponse,
message: message
});
}
});
}

// Natural Language match
robot.on(DELETE_ID, (res) => {
robot.logger.debug(`${TAG}: ${DELETE_ID} - Natural Language match - res.message.text=${res.message.text}.`);
Expand Down
2 changes: 0 additions & 2 deletions src/scripts/redis.nottls.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ module.exports = (robot) => {

function processMonitorNoTtlsWrapper(res) {
if (currentMonitor) {
// return, I'm already monitoring so I can't help you
// this is a stopgap until we can get true multi-user support in place
let warning = i18n.__('monitor.ttls.busy');
robot.emit('ibmcloud.formatter', {
response: res,
Expand Down
20 changes: 11 additions & 9 deletions src/scripts/redis.slowlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ let lastResponse;

module.exports = (robot) => {

redis.on('error', function(err) {
if (lastResponse) {
let message = i18n.__('redis.error', err);
robot.emit('ibmcloud.formatter', {
response: lastResponse,
message: message
});
}
});
if (redis) {
redis.on('error', function(err) {
if (lastResponse) {
let message = i18n.__('redis.error', err);
robot.emit('ibmcloud.formatter', {
response: lastResponse,
message: message
});
}
});
}

// Natural Language match
robot.on(SLOWLOG_ID, (res) => {
Expand Down

0 comments on commit 590d1e8

Please sign in to comment.