How to get an alert when a script finishes with errors

663 views
Skip to first unread message

Guido van den Born

unread,
May 29, 2020, 7:51:04 AM5/29/20
to Google Ads Scripts Forum
Hi all,

I'm looking for the best way to get an alert when a script has failed to run successfully (because of an error in the code, out of runtime (30min+), or maybe there's an error in the spreadsheet it's referencing etc.).

Preferably these alerts would be sent via e-mail or slack. I've found a method that works well, but isn't perfect. I'm curious to hear if anyone knows the best approach to this. I'm also curious to just hear any experiences anyone might have with this. What should I maybe be aware of?


Thanks in advance!
Message has been deleted

Sigurd

unread,
Jun 4, 2020, 11:30:01 AM6/4/20
to Google Ads Scripts Forum
Hi Guido,

So, timeouts are somewhat tricky as they are not execution errors but Google who shuts your execution down - so you cannot easily catch these errors with traditional error handling like try/catch or if statements. See this on how to handle execution errors https://www.w3schools.com/js/js_errors.asp

I believe it is possible to get remaining execution time, so you could build some logic into your scripts to prevent them from timing out in the first place. And/or use labels to ensure that the script can pick up where it left on next execution if it times out.

A few more ideas I can think of: Have the script do something extra as the very last thing. E.g. ping you. Or, if you only wish notifications when it fails, have it write today's date to a specific cell in a Google spreadsheet. You can then have another script to run in that spreadsheet, that will notify you if the date is not set to today's date.

 sigurd

Guido van den Born

unread,
Jun 5, 2020, 4:36:18 AM6/5/20
to Google Ads Scripts Forum
Hi Sigurd,

Thanks for taking the time to help me. Those are some great, inventive suggestions and I think that might just do the trick. I'll definitely give it a go.

Thanks!

Op donderdag 4 juni 2020 17:30:01 UTC+2 schreef Sigurd:
Reply all
Reply to author
Forward
0 new messages