mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
Fix bug with errorCode in Mibew API execution context
This commit is contained in:
parent
8fc9b85bfa
commit
709623dfc5
@ -18,4 +18,4 @@ MibewAPIInteraction.prototype.getObligatoryArgumentsDefaults=function(a){var b={
|
|||||||
function MibewAPIExecutionContext(){this.returnValues={};this.functionsResults=[]}
|
function MibewAPIExecutionContext(){this.returnValues={};this.functionsResults=[]}
|
||||||
MibewAPIExecutionContext.prototype.getArgumentsList=function(a){var b=a.arguments,c=a.arguments.references,d,f,e;for(e in c)if(c.hasOwnProperty(e)){f=c[e];if("undefined"==typeof this.functionsResults[f-1])throw Error("Wrong reference in '"+a["function"]+"' function. Function #"+f+" does not call yet.");if("undefined"==typeof b[e]||""==b[e])throw Error("Wrong reference in '"+a["function"]+"' function. Empty '"+e+"' argument.");d=b[e];if("undefined"==typeof this.functionsResults[f-1][d])throw Error("Wrong reference in '"+
|
MibewAPIExecutionContext.prototype.getArgumentsList=function(a){var b=a.arguments,c=a.arguments.references,d,f,e;for(e in c)if(c.hasOwnProperty(e)){f=c[e];if("undefined"==typeof this.functionsResults[f-1])throw Error("Wrong reference in '"+a["function"]+"' function. Function #"+f+" does not call yet.");if("undefined"==typeof b[e]||""==b[e])throw Error("Wrong reference in '"+a["function"]+"' function. Empty '"+e+"' argument.");d=b[e];if("undefined"==typeof this.functionsResults[f-1][d])throw Error("Wrong reference in '"+
|
||||||
a["function"]+"' function. There is no '"+d+"' argument in #"+f+" function results");b[e]=this.functionsResults[f-1][d]}return b};MibewAPIExecutionContext.prototype.getResults=function(){return this.returnValues};
|
a["function"]+"' function. There is no '"+d+"' argument in #"+f+" function results");b[e]=this.functionsResults[f-1][d]}return b};MibewAPIExecutionContext.prototype.getResults=function(){return this.returnValues};
|
||||||
MibewAPIExecutionContext.prototype.storeFunctionResults=function(a,b){var c,d;for(d in a.arguments["return"])if(a.arguments["return"].hasOwnProperty(d)){c=a.arguments["return"][d];if("undefined"==typeof b[d])throw Error("Variable with name '"+d+"' is undefined in the results of the '"+a["function"]+"' function");this.returnValues[c]=b[d]}this.functionsResults.push(b)};
|
MibewAPIExecutionContext.prototype.storeFunctionResults=function(a,b){var c;if(b.errorCode)this.returnValues.errorCode=b.errorCode,this.returnValues.errorMessage=b.errorMessage||"";else for(var d in a.arguments["return"])if(a.arguments["return"].hasOwnProperty(d)){c=a.arguments["return"][d];if("undefined"==typeof b[d])throw Error("Variable with name '"+d+"' is undefined in the results of the '"+a["function"]+"' function");this.returnValues[c]=b[d]}this.functionsResults.push(b)};
|
||||||
|
@ -470,6 +470,8 @@ MibewAPIExecutionContext.prototype.getResults = function(){
|
|||||||
*/
|
*/
|
||||||
MibewAPIExecutionContext.prototype.storeFunctionResults = function(functionObject, results) {
|
MibewAPIExecutionContext.prototype.storeFunctionResults = function(functionObject, results) {
|
||||||
var alias;
|
var alias;
|
||||||
|
// Check if function return correct results
|
||||||
|
if (!results.errorCode) {
|
||||||
// Add value to request results
|
// Add value to request results
|
||||||
for (var argName in functionObject.arguments["return"]) {
|
for (var argName in functionObject.arguments["return"]) {
|
||||||
if (! functionObject.arguments["return"].hasOwnProperty(argName)) {
|
if (! functionObject.arguments["return"].hasOwnProperty(argName)) {
|
||||||
@ -485,6 +487,12 @@ MibewAPIExecutionContext.prototype.storeFunctionResults = function(functionObjec
|
|||||||
}
|
}
|
||||||
this.returnValues[alias] = results[argName];
|
this.returnValues[alias] = results[argName];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Something went wrong during function execution
|
||||||
|
// Store error code and error message
|
||||||
|
this.returnValues.errorCode = results.errorCode;
|
||||||
|
this.returnValues.errorMessage = results.errorMessage || '';
|
||||||
|
}
|
||||||
// Store function results in execution context
|
// Store function results in execution context
|
||||||
this.functionsResults.push(results);
|
this.functionsResults.push(results);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,8 @@ Class MibewAPIExecutionContext {
|
|||||||
* @throws MibewAPIException
|
* @throws MibewAPIException
|
||||||
*/
|
*/
|
||||||
public function storeFunctionResults ($function, $results) {
|
public function storeFunctionResults ($function, $results) {
|
||||||
|
// Check if function return correct results
|
||||||
|
if (empty($results['errorCode'])) {
|
||||||
// Add value to request results
|
// Add value to request results
|
||||||
foreach ($function['arguments']['return'] as $name => $alias) {
|
foreach ($function['arguments']['return'] as $name => $alias) {
|
||||||
if (! isset($results[$name])) {
|
if (! isset($results[$name])) {
|
||||||
@ -110,6 +112,15 @@ Class MibewAPIExecutionContext {
|
|||||||
}
|
}
|
||||||
$this->return[$alias] = $results[$name];
|
$this->return[$alias] = $results[$name];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Something went wrong during function execution
|
||||||
|
// Store error code and error message
|
||||||
|
$this->return['errorCode'] = $results['errorCode'];
|
||||||
|
$this->return['errorMessage'] = empty($results['errorMessage'])
|
||||||
|
? ''
|
||||||
|
: $results['errorMessage'];
|
||||||
|
}
|
||||||
|
|
||||||
// Store function results in execution context
|
// Store function results in execution context
|
||||||
$this->functions_results[] = $results;
|
$this->functions_results[] = $results;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user