From: Michal Michalski Date: Fri, 26 Oct 2018 12:51:01 +0000 (+0200) Subject: Fix for functions throwing exceptions unspecified by documentation. X-Git-Tag: submit/tizen_5.0/20181102.061247~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f6530130fc058d9fccecfed913204d75188a32b;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git Fix for functions throwing exceptions unspecified by documentation. Functions for removing listeners threw exceptions if listener id was not registered. This behavior was not specified in docs. This commit disables those exception and silently returns from functions if listener for given id is not found. [Verification] TCT tests which call changed api functions passed. Change-Id: I8fe1a07ade9a35bfbfa95c1a628eeff95a420e0f Signed-off-by: Michal Michalski --- diff --git a/src/sound/sound_api.js b/src/sound/sound_api.js index 0eb82444..a72f8123 100644 --- a/src/sound/sound_api.js +++ b/src/sound/sound_api.js @@ -79,13 +79,12 @@ ListenerManager.prototype.addListener = function(callback) { }; ListenerManager.prototype.removeListener = function(watchId) { - if (this.listeners.hasOwnProperty(watchId)) { - delete this.listeners[watchId]; - } else { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - 'Listener with id: ' + watchId + ' does not exist.'); + if (!this.listeners.hasOwnProperty(watchId)) { + return; } + delete this.listeners[watchId]; + if (this.nativeSet && type_.isEmptyObject(this.listeners)) { this.native.callSync('SoundManager_removeDeviceStateChangeListener'); this.native.removeListener(this.listenerName); diff --git a/src/widgetservice/widgetservice_api.js b/src/widgetservice/widgetservice_api.js index 0ec0275d..a534fd28 100644 --- a/src/widgetservice/widgetservice_api.js +++ b/src/widgetservice/widgetservice_api.js @@ -345,7 +345,7 @@ ListenerManager.prototype.addListener = function(callback) { ListenerManager.prototype.removeListener = function(watchId) { if (this.listeners[watchId] === null || this.listeners[watchId] === undefined) { - throw new WebAPIException(0, 'Watch id not found.', 'NotFoundError'); + return; } if (this.listeners.hasOwnProperty(watchId)) {