Error handling with Node Redis client

I am using the Node Redis client library and am looking to design my error handling logic. Could someone help answer the following problem?

In short, I need to know if a write operation (including transactions, and scripts) succeeded or not.

Specifically, I'm thinking about the case where the client disconnects. I see three scenarios:

1) The client disconnects before the operation(s) started 2) The operation(s) start, but fail, but the client disconnects before the error message is reported 3) The operation(s) start and succeed, but the client disconnects before the response is reported

Each scenario would potentially require a different action (1 might just retry the command, 2 might understand why the command failed before retrying, 3 might fetch the response that would have been returned).

How can I determine which outcome has occurred?

The case you are trying to solve suits for the promise library called bluebird.

You want to handle multiple different types of errors like this:

try {
    //code
}
catch(e) {
    if( e instanceof WhatIWantError) {
        //handle
    }
    else {
        throw e;
    }
}

Now the bluebird allows this in even better way:

var fs = Promise.promisifyAll(require("fs"));

fs.readFileAsync("myfile.json").then(JSON.parse).then(function (json) {
    console.log("Successful json")
}).catch(SyntaxError, function (e) {
    console.error("file contains invalid json");
}).catch(Promise.OperationalError, function (e) {
    console.error("unable to read file, because: ", e.message);
});