Skip to content

Commit

Permalink
throw user friendly error message for "service invoked too many times…
Browse files Browse the repository at this point in the history
…" error from UrlFetchApp
  • Loading branch information
diosmosis committed Oct 2, 2024
1 parent ba28482 commit 99d4e48
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,14 @@ export function fetchAll(requests: MatomoRequestParams[], options: ApiFetchOptio
try {
responses = UrlFetchApp.fetchAll(urlsToFetch);
} catch (e) {
// only rethrow for unknown errors, otherwise retry
const errorMessage = e.message || e;

// throw user friendly error messages if possible
if (errorMessage && errorMessage.toLowerCase().includes('service invoked too many times for one day: urlfetch')) {
throwUserError('The "urlfetch" daily quota for your account has been reached, further requests for today may not work. See https://developers.google.com/apps-script/guides/services/quotas for more information.');
}

// only rethrow for unknown errors, otherwise retry
if (!errorMessage
|| (
!errorMessage.toLowerCase().includes('address unavailable')
Expand Down

0 comments on commit 99d4e48

Please sign in to comment.