THRIFT-5674: Catch and handle server implementation exceptions
Client: js:es6
diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc
index fbd657e..f5937d0 100644
--- a/compiler/cpp/src/thrift/generate/t_js_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc
@@ -1485,7 +1485,7 @@
   indent_up();
 
   if (gen_es6_) {
-    indent(f_service_) << "Promise.resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << endl;
+    indent(f_service_) << "new Promise((resolve) => resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << endl;
   } else {
     string maybeComma = (fields.size() > 0 ? "," : "");
     indent(f_service_) << "Q.fcall(this._handler." << tfunction->get_name() << ".bind(this._handler)"
@@ -1500,7 +1500,7 @@
   indent_down();
 
   if (gen_es6_) {
-    indent(f_service_) << ")).then(result => {" << endl;
+    indent(f_service_) << "))).then(result => {" << endl;
   } else {
     indent(f_service_) << ").then(function(result) {" << endl;
   }
diff --git a/tutorial/nodejs/NodeClientPromise.js b/tutorial/nodejs/NodeClientPromise.js
index 2cdc184..e6ff2d7 100644
--- a/tutorial/nodejs/NodeClientPromise.js
+++ b/tutorial/nodejs/NodeClientPromise.js
@@ -57,7 +57,7 @@
   .then(function(message) {
 	console.log('Whoa? You know how to divide by zero?');
   })
-  .fail(function(err) {
+  .catch(function(err) {
     console.log("InvalidOperation " + err);
   });
 
@@ -74,7 +74,7 @@
   .then(function(message) {
       console.log('Check log: ' + message.value);
   })
-  .fin(function() {
+  .finally(function() {
 	  //close the connection once we're done
       connection.end();
   });