Can you let us know what you are trying to achieve here ? The cloud code debugger should be quite helpful to you for this. With “Break On Error” enabled in the debugger should your script hit a breakpoint it will stop executing and return an error. Alternatively you could put your code into a function and surround it with a try/catch and return if a catch is called.
Thanks,
Liam
I
Irakli Geleishvili
said
over 5 years ago
Hello Liam,
I want to add to Cloud Code beginning something like this:
if (userScore < 0){
// I'm searching something to put here. I want to tell GS to don't execute code after this if statement and send response with script data. Usually "return" is used for this in scripting but it doesn't work here.
}
// Some long code here, which shouldn't execute if userScore < 0
Of course I can place everything after if statement in "else" and It wouldn't run, but I frequently set filters using "return" and am interested to find this in GS too.
Thanks!
I
Irakli Geleishvili
said
over 5 years ago
OK, I'll put it into "else". :)
Anyway, I'll be glad to hear if there's a "return" command.
B
Baris Tumerkan
said
over 5 years ago
You can put all of your code for that event in a function, and call that function. Then you can call return in the function as you want.
G
Greg Quinn
said
about 4 years ago
Answer
You can use Spark.exit(); to stop code execution.
If you have an error, you can set it as script data, then call Spark.exit();
i.e
Spark.setScriptError("error", "This is my error that happened")
Spark.exit();
Irakli Geleishvili
Is there a way to stop/break Cloud Code execution and return script data?
if(something wrong){
break and return some script data;
}
continue script
You can use Spark.exit(); to stop code execution.
If you have an error, you can set it as script data, then call Spark.exit();
i.e
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Irakli,
Can you let us know what you are trying to achieve here ? The cloud code debugger should be quite helpful to you for this. With “Break On Error” enabled in the debugger should your script hit a breakpoint it will stop executing and return an error. Alternatively you could put your code into a function and surround it with a try/catch and return if a catch is called.
Thanks,
Liam
Irakli Geleishvili
Hello Liam,
I want to add to Cloud Code beginning something like this:
if (userScore < 0){
// I'm searching something to put here. I want to tell GS to don't execute code after this if statement and send response with script data. Usually "return" is used for this in scripting but it doesn't work here.
}
// Some long code here, which shouldn't execute if userScore < 0
Of course I can place everything after if statement in "else" and It wouldn't run, but I frequently set filters using "return" and am interested to find this in GS too.
Thanks!
Irakli Geleishvili
OK, I'll put it into "else". :)
Anyway, I'll be glad to hear if there's a "return" command.
Baris Tumerkan
You can put all of your code for that event in a function, and call that function. Then you can call return in the function as you want.
Greg Quinn
You can use Spark.exit(); to stop code execution.
If you have an error, you can set it as script data, then call Spark.exit();
i.e
Irakli Geleishvili
Hi Greg,
Spark.exit() was what I needed at that moment.
Thanks!
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2486 topics