1

Question

There are various quota limits in Apps Script.

Is there a way to catch the error thrown when a quota limit is met and script/custom function terminated prematurely?

For example, if a script executed through the GUI is run for over 6 minutes, the user will be prompted with a message in red background that the "execution exceeded maximum time". Is there a way to catch this without the GUI?


Note:

I am not asking for optimization in Apps Script. There would be many duplicate questions and excellent answers in that regard. I understand there is no workaround to the hard quotas. I just want to catch whenever a quota limit is reached.

The context is that I am scraping data from a site in China that outputs an image which is in turn converted from numerical data in real time. The distance to server, the typical slow response of Chinese government sites, and the real time conversion are the (unavoidable) reasons for timeouts.

Argyll
  • 8,591
  • 4
  • 25
  • 46
  • AFAIK, No. Even though I don't think you can `catch`, You can get that information on demand with [tag:google-apps-script-api] – TheMaster Jan 15 '19 at 15:05
  • 1
    The GAS quotas [documentation](https://developers.google.com/apps-script/guides/services/quotas#exception_messages) intriguingly states "If a script reaches a quota or limitation, it will throw an exception with a message similar to the following:..." which suggests something like a try..catch block would work. But I can't find an example of this being done anywhere. If you use Stackdriver then you can find the quota messages there, but this is obviously after the event. The only other suggestion is to maintain your own counter, so you will know when you have hit the limit. – P Burke Jan 15 '19 at 19:02
  • I may be a lot late on getting to answer this but I just posted a similar answer here - https://stackoverflow.com/a/58674371/10713297 . Hope that helps :) – Sourabh Choraria Nov 02 '19 at 20:29
  • @Sourabh Choraria: Thanks for the answer and the link. :) – Argyll Nov 04 '19 at 00:17

0 Answers0