[Sound] Throw exception if listener does not exists.
authorTomasz Marciniak <t.marciniak@samsung.com>
Mon, 18 May 2015 13:51:42 +0000 (15:51 +0200)
committerTomasz Marciniak <t.marciniak@samsung.com>
Mon, 18 May 2015 13:51:42 +0000 (15:51 +0200)
[Verification] Code compiles without errors.
Manual test SoundManager_removeDeviceStateChangeListener passes.

Change-Id: I81cd390cbed3eff74f97211c34de464c198fa5d8
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/sound/sound_api.js

index 2460657374576328cde3b937dd45a1e5c119394a..e4a7a98f50a6a7b39a2c0d3b7ae872ba31a021dc 100644 (file)
@@ -71,6 +71,9 @@ 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.nativeSet && type_.isEmptyObject(this.listeners)) {