summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfarrell <jfarrell@apache.org>2016-09-15 23:37:43 -0400
committerjfarrell <jfarrell@apache.org>2016-09-15 23:38:58 -0400
commit205dc19556eac3c0ab2d1965c4636b78f8922fae (patch)
tree3e00430d5c3d021761afed3977b7c0bf28d58a36
parentddc53c32486cc23dfa63ed4e5abb19923b8d13e6 (diff)
downloadthrift-205dc19556eac3c0ab2d1965c4636b78f8922fae.tar.gz
THRIFT-3927: Emit an error instead of throw an error in the async callback
Client: node Patch: lifei Because the data event of a connection is async handled, throw an exception can not tell the code the error. emit the error should be the correct way to handle the errors. Closes #1087
-rw-r--r--lib/nodejs/lib/thrift/connection.js2
-rw-r--r--lib/nodejs/lib/thrift/http_connection.js2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/nodejs/lib/thrift/connection.js b/lib/nodejs/lib/thrift/connection.js
index 23cb01c79..575d51694 100644
--- a/lib/nodejs/lib/thrift/connection.js
+++ b/lib/nodejs/lib/thrift/connection.js
@@ -150,7 +150,7 @@ var Connection = exports.Connection = function(stream, options) {
transport_with_data.rollbackPosition();
}
else {
- throw e;
+ self.emit('error', e);
}
}
}));
diff --git a/lib/nodejs/lib/thrift/http_connection.js b/lib/nodejs/lib/thrift/http_connection.js
index f3fcd7411..18bfadbc4 100644
--- a/lib/nodejs/lib/thrift/http_connection.js
+++ b/lib/nodejs/lib/thrift/http_connection.js
@@ -157,7 +157,7 @@ var HttpConnection = exports.HttpConnection = function(host, port, options) {
if (e instanceof InputBufferUnderrunError) {
transport_with_data.rollbackPosition();
} else {
- throw e;
+ self.emit('error', e);
}
}
}