You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/08 22:48:50 UTC
incubator-ignite git commit: #ignite-961: [server.js] Catch only
JSON.parse exceptions
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-961 fb67ebcfc -> bc4a4e3a8
#ignite-961: [server.js] Catch only JSON.parse exceptions
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bc4a4e3a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bc4a4e3a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bc4a4e3a
Branch: refs/heads/ignite-961
Commit: bc4a4e3a85d2be628f746a9444190a72f281b807
Parents: fb67ebc
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jun 8 23:48:41 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jun 8 23:48:41 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/server.js | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc4a4e3a/modules/nodejs/src/main/js/server.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/server.js b/modules/nodejs/src/main/js/server.js
index 99c3531..224db8b 100644
--- a/modules/nodejs/src/main/js/server.js
+++ b/modules/nodejs/src/main/js/server.js
@@ -79,18 +79,20 @@ Server.prototype.runCommand = function(cmdName, params, callback) {
});
response.on('end', function () {
+ var response;
try {
- var response = JSON.parse(fullResponseString);
-
- if (response.successStatus) {
- callback.call(null, response.error, null)
- }
- else {
- callback.call(null, null, response.response);
- }
+ response = JSON.parse(fullResponseString);
}
catch (e) {
callback.call(null, e, null);
+ return;
+ }
+
+ if (response.successStatus) {
+ callback.call(null, response.error, null)
+ }
+ else {
+ callback.call(null, null, response.response);
}
});
}