1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Make sure the ScriptJob fails if script does not return an object for a request

This commit is contained in:
Dominik Schmidt
2014-12-05 05:02:50 +01:00
parent 558e6f5294
commit 507df5317e

View File

@@ -608,12 +608,22 @@ Tomahawk.PluginManager = {
invoke: function (requestId, objectId, methodName, params ) { invoke: function (requestId, objectId, methodName, params ) {
this.objects[objectId][methodName](params).then(function (result) { this.objects[objectId][methodName](params).then(function (result) {
if (typeof result === 'object') {
Tomahawk.reportScriptJobResults({ Tomahawk.reportScriptJobResults({
requestId: requestId, requestId: requestId,
data: result data: result
}); });
} else {
Tomahawk.reportScriptJobResults({
requestId: requestId,
error: "Scripts need to return objects for requests"
});
}
}, function (error) { }, function (error) {
Tomahawk.reportScriptJobResults({error: error}); Tomahawk.reportScriptJobResults({
requestId: requestId,
error: error
});
}); });
} }
}; };