You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Improve error handling
Added individual error classes Don't silently fail for commands without callback from now on General polishing (e.g. better error messages) Fix typos
This commit is contained in:
@@ -31,7 +31,7 @@ describe("The 'dbsize' method", function () {
|
||||
|
||||
it('reports an error', function (done) {
|
||||
client.dbsize([], function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -31,7 +31,7 @@ describe("The 'flushdb' method", function () {
|
||||
|
||||
it('reports an error', function (done) {
|
||||
client.flushdb(function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -31,14 +31,14 @@ describe("The 'get' method", function () {
|
||||
|
||||
it('reports an error', function (done) {
|
||||
client.get(key, function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('reports an error promisified', function () {
|
||||
return client.getAsync(key).then(assert, function (err) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -32,7 +32,7 @@ describe("The 'getset' method", function () {
|
||||
|
||||
it('reports an error', function (done) {
|
||||
client.get(key, function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -24,8 +24,10 @@ describe("The 'hgetall' method", function () {
|
||||
it('handles simple keys and values', function (done) {
|
||||
client.hmset(['hosts', '__proto__', '1', 'another', '23', 'home', '1234'], helper.isString('OK'));
|
||||
client.HGETALL(['hosts'], function (err, obj) {
|
||||
assert.strictEqual(3, Object.keys(obj).length);
|
||||
assert.strictEqual('1', obj.__proto__.toString()); // eslint-disable-line no-proto
|
||||
if (!/^v0\.10/.test(process.version)) {
|
||||
assert.strictEqual(3, Object.keys(obj).length);
|
||||
assert.strictEqual('1', obj.__proto__.toString()); // eslint-disable-line no-proto
|
||||
}
|
||||
assert.strictEqual('23', obj.another.toString());
|
||||
assert.strictEqual('1234', obj.home.toString());
|
||||
done(err);
|
||||
|
@@ -33,7 +33,7 @@ describe("The 'mset' method", function () {
|
||||
|
||||
it('reports an error', function (done) {
|
||||
client.mset(key, value, key2, value2, function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -96,7 +96,8 @@ describe("The 'mset' method", function () {
|
||||
// this behavior is different from the 'set' behavior.
|
||||
it('emits an error', function (done) {
|
||||
client.on('error', function (err) {
|
||||
assert.equal(err.message, "ERR wrong number of arguments for 'mset' command");
|
||||
assert.strictEqual(err.message, "ERR wrong number of arguments for 'mset' command");
|
||||
assert.strictEqual(err.name, 'ReplyError');
|
||||
done();
|
||||
});
|
||||
|
||||
|
@@ -23,7 +23,7 @@ describe("The 'select' method", function () {
|
||||
|
||||
it('returns an error if redis is not connected', function (done) {
|
||||
var buffering = client.select(1, function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
done();
|
||||
});
|
||||
assert(typeof buffering === 'boolean');
|
||||
|
@@ -31,7 +31,7 @@ describe("The 'set' method", function () {
|
||||
|
||||
it('reports an error', function (done) {
|
||||
client.set(key, value, function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
assert(err.message.match(/The connection is already closed/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user