1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-11 22:42:42 +03:00

Improve error handling

Arguments are now passed to an command error in case they exist
An error is only emitted if that very same error is not already handled in a callback
This commit is contained in:
Ruben Bridgewater
2016-04-14 02:08:12 +02:00
parent 97ae78877b
commit a857829a36
8 changed files with 103 additions and 46 deletions

16
lib/customError.js Normal file
View File

@@ -0,0 +1,16 @@
'use strict';
var util = require('util');
function CommandError (error) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = error.message;
for (var keys = Object.keys(error), key = keys.pop(); key; key = keys.pop()) {
this[key] = error[key];
}
}
util.inherits(CommandError, Error);
module.exports = CommandError;