From bbdbb8983859a8fdd17d7abba54701c575edf515 Mon Sep 17 00:00:00 2001 From: Jared Noble Date: Wed, 12 Apr 2017 09:52:47 -0700 Subject: [PATCH] better error parsing for open --- src/webhdfs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/webhdfs.js b/src/webhdfs.js index f2e7502..94185bb 100644 --- a/src/webhdfs.js +++ b/src/webhdfs.js @@ -319,6 +319,7 @@ WebHDFSClient.prototype.open = function (path, hdfsoptions, requestoptions, call // format request args var args = _.defaults({ + json: true, uri: this.base_url + path, qs: _.defaults({ op: 'open' @@ -330,7 +331,10 @@ WebHDFSClient.prototype.open = function (path, hdfsoptions, requestoptions, call // forward request error if (error) return callback(error); - + + if (typeof body === 'object' && 'RemoteException' in body){ + return callback(new RemoteException(body)); + } // execute callback return callback(null, body);