From b5588ae16bae6ac6813991ecbe2c998a86adfaab Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Thu, 3 Jan 2019 11:08:47 +0800 Subject: [PATCH 1/2] added API_NOT_ENABLED (Google project not found). Since it likely requires action from the developer, added as a NORETRY --- src/ErrorHandler.gs.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ErrorHandler.gs.js b/src/ErrorHandler.gs.js index e2de5a0..1a7da7c 100644 --- a/src/ErrorHandler.gs.js +++ b/src/ErrorHandler.gs.js @@ -489,6 +489,7 @@ NORMALIZED_ERRORS = { SERVICE_ERROR: "Service error", INVALID_ARGUMENT: 'Invalid argument', SHEET_ALREADY_EXISTS_PLEASE_ENTER_ANOTHER_NAME: 'A sheet with this name already exists. Please enter another name.', + API_NOT_ENABLED: 'Project is not found and cannot be used for API calls', }; /** @@ -523,6 +524,7 @@ NORETRY_ERRORS[NORMALIZED_ERRORS.AUTHORIZATION_REQUIRED] = true; NORETRY_ERRORS[NORMALIZED_ERRORS.INVALID_ARGUMENT] = true; NORETRY_ERRORS[NORMALIZED_ERRORS.ACTION_NOT_ALLOWED_THROUGH_EXEC_API] = true; NORETRY_ERRORS[NORMALIZED_ERRORS.DAILY_LIMIT_EXCEEDED] = true; +NORETRY_ERRORS[NORMALIZED_ERRORS.API_NOT_ENABLED] = true; // noinspection JSUnusedGlobalSymbols, ThisExpressionReferencesGlobalObjectJS this['ErrorHandler'] = { @@ -823,6 +825,9 @@ ErrorHandler_._ERROR_MESSAGE_TRANSLATIONS = { // "The Google Calendar is not enabled for the user." - eg: CalendarApp.getDefaultCalendar() "The Google Calendar is not enabled for the user.": { ref: NORMALIZED_ERRORS.CALENDAR_SERVICE_NOT_ENABLED, locale: 'en'}, + + // If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. + "If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.": { ref: NORMALIZED_ERRORS.API_NOT_ENABLED, locale: 'en'} }; /** @@ -1037,6 +1042,10 @@ ErrorHandler_._ERROR_PARTIAL_MATCH = [ variables: ['sheetName'], ref: NORMALIZED_ERRORS.SHEET_ALREADY_EXISTS_PLEASE_ENTER_ANOTHER_NAME, locale: 'sk'}, + {regex: /^Project ([0-9]+) is not found and cannot be used for API calls\. If it is recently created, enable (.*) by visiting (.*) then retry\. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry\.$/, + variables: ['projectId', 'apiName', 'consoleUrl'], + ref: NORMALIZED_ERRORS.API_NOT_ENABLED, + locale: 'en'}, ]; /** From 857505f41cba3972c1bb13bb64900dcd9872a573 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Thu, 3 Jan 2019 11:29:53 +0800 Subject: [PATCH 2/2] more consistent naming for localization --- src/ErrorHandler.gs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ErrorHandler.gs.js b/src/ErrorHandler.gs.js index 1a7da7c..326122d 100644 --- a/src/ErrorHandler.gs.js +++ b/src/ErrorHandler.gs.js @@ -826,8 +826,8 @@ ErrorHandler_._ERROR_MESSAGE_TRANSLATIONS = { // "The Google Calendar is not enabled for the user." - eg: CalendarApp.getDefaultCalendar() "The Google Calendar is not enabled for the user.": { ref: NORMALIZED_ERRORS.CALENDAR_SERVICE_NOT_ENABLED, locale: 'en'}, - // If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. - "If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.": { ref: NORMALIZED_ERRORS.API_NOT_ENABLED, locale: 'en'} + // Google Project not found. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. + "Google Project not found. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.": { ref: NORMALIZED_ERRORS.API_NOT_ENABLED, locale: 'en'} }; /**