I’ve created a script to send SMS notifications once important message is received (in accordance with this tutorial).
But quite often I receive notifications, that script failed to finish successfully. Error message is Cannot connect to Gmail (line 13), line 13 is:
var threads = GmailApp.getUserLabelByName('SMS').getThreads();
How should I handle it? I.e. just to stop execution and wait for next run?
A nice way would be to wrap your code around in a while loop and a try catch block and try until the operation is successful.
Something like …