I've created a google app script that runs on a Google Sheets file. Every day at ~9am a trigger runs on of my functions.
Every few days (I don't know why) but I get an
Execution Error: Service invoked too many times for one day: urlfetch
I've given up trying to solve that issue, but it would be great if at the end of my function I could include some code to check if there was an execution error and if so run another function e.g.
myfunction_9am() {
<try run some code>
if (execution Status = "Failed") { <<this is the bit I don't know how to code
myfunction_error();
}
}
try{ //Some code }catch(e) {//Code to run only if there is an error}The letterein the parenthesis is an "exception object" that contains a JavaScript error message, and the "stack." If the catch block runs code, then the execution failed. You don't need to test for whether it failed or not. To get the error message usee.messageand to get the stack usee.stack.