Skip to content

Commit 99d2757

Browse files
committed
fix: provide details error when connection is failed
1 parent 498a077 commit 99d2757

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

client/actions.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import _ from 'lodash';
88
const actions = {
99
connect(config) {
1010
return dispatch => {
11-
let sshErrorThrown = false
11+
let sshErrorThrown = false;
12+
let redisErrorThrown = false;
13+
let redisErrorMessage;
1214
if (config.ssh) {
1315
dispatch({ type: 'updateConnectStatus', data: 'SSH connecting...' });
1416
const conn = new Client();
@@ -26,7 +28,7 @@ const actions = {
2628
});
2729
})
2830
.on('error', err => {
29-
sshErrorThrown = true
31+
sshErrorThrown = true;
3032
dispatch({ type: 'disconnect' });
3133
alert(`SSH Error: ${err.message}`);
3234
});
@@ -85,8 +87,10 @@ const actions = {
8587
if (err.message === 'Ready check failed: NOAUTH Authentication required.') {
8688
err.message = 'Redis Error: Access denied. Please double-check your password.';
8789
}
88-
alert(err.message);
89-
dispatch({ type: 'disconnect' });
90+
if (err.message !== 'Connection is closed.') {
91+
alert(err.message);
92+
redis.disconnect();
93+
}
9094
return;
9195
}
9296
const version = redis.serverInfo.redis_version;
@@ -101,10 +105,17 @@ const actions = {
101105
dispatch({ type: 'connect', data: { redis, config } });
102106
})
103107
});
108+
redis.once('error', function (error) {
109+
redisErrorMessage = error;
110+
});
104111
redis.once('end', function () {
105112
dispatch({ type: 'disconnect' });
106113
if (!sshErrorThrown) {
107-
alert('Redis Error: Connection failed');
114+
let msg = 'Redis Error: Connection failed. ';
115+
if (redisErrorMessage) {
116+
msg += `(${redisErrorMessage})`;
117+
}
118+
alert(msg);
108119
}
109120
});
110121
}

0 commit comments

Comments
 (0)