ryancole/node-webhdfs — pull request #6 by ecogodi (2014-10-03 13:35:07+00:00)
Title: Added class for Remote Exceptions and used it for exception handling 

Added class for Remote Exceptions and used it for remote exception handling instead of plain Error objects.

In particular, the remote_exception.exception string is populated from the corresponding property of the response body and can be used by calling code to act on particular exceptions. The constructor is exported for type checking:

webHdfs = require("node-webhdfs"),
...
this._hdfs_client.listStatus(directory, function (err, res) {
if(err instanceof webHdfs.RemoteException ){
if(err.exception == 'FileNotFoundException')
< act on specific exception class >
}
...

The constructor takes either a message string, exception string couple, or the service response object as-is.