3rd-Eden/node-memcached — pull request #73 by sebastianseilund (2012-11-28 23:18:14+00:00)
Title: Changed all errors to be instances of Error instead of plain strings

Hi

This makes debugging a lot easier, and adds to the module's robustness.

The error for "Item is not stored" has a special use case, as it's something you expect could happen. The error object for this error message has a notStore=true property. It's useful like this:

memcached.add('only-set-me-once', Date.now(), 0, function(err) {
if (err && !err.notStored)) {
//Only throw the error, if it wasn't the notStored "error", which we expect to happen sometimes.
throw err;
}
//Callback or whatever you wanna do
});

Unit tests pass after the changes.

Sebastian