From 507df5317e7aabb9c7e1fe138e2fe01c240a450e Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 5 Dec 2014 05:02:50 +0100 Subject: [PATCH] Make sure the ScriptJob fails if script does not return an object for a request --- data/js/tomahawk.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/data/js/tomahawk.js b/data/js/tomahawk.js index f7a319411..7832725c9 100644 --- a/data/js/tomahawk.js +++ b/data/js/tomahawk.js @@ -608,12 +608,22 @@ Tomahawk.PluginManager = { invoke: function (requestId, objectId, methodName, params ) { this.objects[objectId][methodName](params).then(function (result) { + if (typeof result === 'object') { + Tomahawk.reportScriptJobResults({ + requestId: requestId, + data: result + }); + } else { + Tomahawk.reportScriptJobResults({ + requestId: requestId, + error: "Scripts need to return objects for requests" + }); + } + }, function (error) { Tomahawk.reportScriptJobResults({ requestId: requestId, - data: result + error: error }); - }, function (error) { - Tomahawk.reportScriptJobResults({error: error}); }); } };