Hi Eric,
You can catch this exception and return it using a try-catch block:
try{
//insert operation here
var res = Spark.runtimeCollection("myCollection").insert(myDoc);
}
catch(e){
//print error message
res = false;
Spark.setScriptError("message",e.message);
}
Spark.setScriptData("result", res);
Hope this helps. If you have any more questions please don't hesitate to contact us.
Regards,
Vinnie
Eric Moncada
When I make an insert in a Spark.runtimeCollection, it should return (according documentation) true or false wether the insert succeed or fail.
If the insert leads to a duplicate key, there is a fatal error on the cloud code line and the script breaks.
I would expect to have false to be able to deal with the case.
1 person has this problem