You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Emit errors instead of throwing them
Thrown errors might kill the users app. By emitting the errors the user is able to catch all errors in one place without the app going down
This commit is contained in:
@@ -647,7 +647,7 @@ describe("The node_redis client", function () {
|
||||
|
||||
describe('enable_offline_queue', function () {
|
||||
describe('true', function () {
|
||||
it("does not throw an error and enqueues operation", function (done) {
|
||||
it("does not return an error and enqueues operation", function (done) {
|
||||
var client = redis.createClient(9999, null, {
|
||||
max_attempts: 1,
|
||||
parser: parser
|
||||
@@ -674,20 +674,18 @@ describe("The node_redis client", function () {
|
||||
});
|
||||
|
||||
describe('false', function () {
|
||||
it("does not throw an error and enqueues operation", function (done) {
|
||||
it("does not emit an error and enqueues operation", function (done) {
|
||||
var client = redis.createClient(9999, null, {
|
||||
parser: parser,
|
||||
max_attempts: 1,
|
||||
enable_offline_queue: false
|
||||
});
|
||||
|
||||
client.on('error', function() {
|
||||
// ignore, b/c expecting a "can't connect" error
|
||||
client.on('error', function(err) {
|
||||
assert(/send_command: stream not writeable|ECONNREFUSED/.test(err.message));
|
||||
});
|
||||
|
||||
assert.throws(function () {
|
||||
client.set('foo', 'bar');
|
||||
});
|
||||
client.set('foo', 'bar');
|
||||
|
||||
assert.doesNotThrow(function () {
|
||||
client.set('foo', 'bar', function (err) {
|
||||
|
Reference in New Issue
Block a user