THRIFT-3356: handle undefined captureStackTrace
Client: nodejs
Patch: Márton Csordás
This closes #2082
diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js
index 69bcccd..c682605 100644
--- a/lib/js/src/thrift.js
+++ b/lib/js/src/thrift.js
@@ -284,7 +284,10 @@
Thrift.TProtocolException = function TProtocolException(type, message) {
Error.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.name = this.constructor.name;
this.type = type;
this.message = message;
diff --git a/lib/nodejs/lib/thrift/header_protocol.js b/lib/nodejs/lib/thrift/header_protocol.js
index 0c3b0db..a037dc2 100644
--- a/lib/nodejs/lib/thrift/header_protocol.js
+++ b/lib/nodejs/lib/thrift/header_protocol.js
@@ -29,7 +29,10 @@
function THeaderProtocolError(message) {
Error.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.name = this.constructor.name;
this.message = message;
}
diff --git a/lib/nodejs/lib/thrift/header_transport.js b/lib/nodejs/lib/thrift/header_transport.js
index c5f133e..252a423 100644
--- a/lib/nodejs/lib/thrift/header_transport.js
+++ b/lib/nodejs/lib/thrift/header_transport.js
@@ -24,7 +24,10 @@
function THeaderTransportError(message) {
Error.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.name = this.constructor.name;
this.message = message;
}
diff --git a/lib/nodejs/lib/thrift/http_connection.js b/lib/nodejs/lib/thrift/http_connection.js
index 3c2ab0f..81e6b70 100644
--- a/lib/nodejs/lib/thrift/http_connection.js
+++ b/lib/nodejs/lib/thrift/http_connection.js
@@ -253,7 +253,10 @@
function THTTPException(response) {
thrift.TApplicationException.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.name = this.constructor.name;
this.statusCode = response.statusCode;
this.response = response;
diff --git a/lib/nodejs/lib/thrift/input_buffer_underrun_error.js b/lib/nodejs/lib/thrift/input_buffer_underrun_error.js
index 72555e5..0e33f5a 100644
--- a/lib/nodejs/lib/thrift/input_buffer_underrun_error.js
+++ b/lib/nodejs/lib/thrift/input_buffer_underrun_error.js
@@ -22,7 +22,10 @@
function InputBufferUnderrunError(message) {
Error.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.name = this.constructor.name;
this.message = message;
};
diff --git a/lib/nodejs/lib/thrift/thrift.js b/lib/nodejs/lib/thrift/thrift.js
index f2b2896..58d4aff 100644
--- a/lib/nodejs/lib/thrift/thrift.js
+++ b/lib/nodejs/lib/thrift/thrift.js
@@ -49,7 +49,10 @@
function TException(message) {
Error.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.name = this.constructor.name;
this.message = message;
};
@@ -73,7 +76,10 @@
function TApplicationException(type, message) {
TException.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.type = type || TApplicationExceptionType.UNKNOWN;
this.name = this.constructor.name;
this.message = message;
@@ -149,7 +155,10 @@
function TProtocolException(type, message) {
Error.call(this);
- Error.captureStackTrace(this, this.constructor);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
this.name = this.constructor.name;
this.type = type;
this.message = message;