From: Jakub Skowron Date: Wed, 8 Feb 2017 09:20:17 +0000 (+0100) Subject: [Utils] Check if response is undefined in callSync X-Git-Tag: submit/tizen_3.0/20170213.112925~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72d29a53b2f6af9aced27e35663ae10514b80324;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Utils] Check if response is undefined in callSync If response is undefined JSON.parse(undefined) throws 'SyntaxError: Unexpected token u', and it goes to top-level. It hides the real cause, which is internal error. Change-Id: Icce09baf8ba007ce7bb754a4f4af89ce2014cd36 Signed-off-by: Jakub Skowron --- diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 5502e3f2..37104554 100644 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -1076,7 +1076,12 @@ NativeManager.prototype.callSync = function(cmd, args) { args: args || {} }); - return JSON.parse(this.extension.internal.sendSyncMessage(request)); + var response = this.extension.internal.sendSyncMessage(request); + if( response === undefined ) { + /* C++ extension didn't set sync response using Instance::SendSyncReply */ + throw new WebAPIException(WebAPIException.ABORT_ERR, "Internal error"); + } + return JSON.parse(response); }; NativeManager.prototype.sendRuntimeMessage = function(msg, body) {