Skip to content

Commit

Permalink
New errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainVialard authored Apr 23, 2018
1 parent bbfba4f commit ce5b591
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/ErrorHandler.gs.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ NORMALIZED_ERRORS = {
DOCUMENT_MISSING: 'Document is missing (perhaps it was deleted?)',
USER_RATE_LIMIT_EXCEEDED_RETRY_AFTER_SPECIFIED_TIME: 'User-rate limit exceeded. Retry after specified time.',
INVALID_ARGUMENT: 'Invalid argument',
SHEET_ALREADY_EXISTS_PLEASE_ENTER_ANOTHER_NAME: 'A sheet with this name already exists. Please enter another name.',
};
NORETRY_ERRORS = {};
NORETRY_ERRORS[NORMALIZED_ERRORS.INVALID_EMAIL] = true;
Expand All @@ -442,6 +443,7 @@ NORETRY_ERRORS[NORMALIZED_ERRORS.TRYING_TO_EDIT_PROTECTED_CELL] = true;
NORETRY_ERRORS[NORMALIZED_ERRORS.AUTHORIZATION_REQUIRED] = true;
NORETRY_ERRORS[NORMALIZED_ERRORS.INVALID_ARGUMENT] = true;
NORETRY_ERRORS[NORMALIZED_ERRORS.NO_RECIPIENT] = true;
NORETRY_ERRORS[NORMALIZED_ERRORS.SHEET_ALREADY_EXISTS_PLEASE_ENTER_ANOTHER_NAME] = true;


// noinspection JSUnusedGlobalSymbols, ThisExpressionReferencesGlobalObjectJS
Expand Down Expand Up @@ -519,6 +521,7 @@ ErrorHandler_._ERROR_MESSAGE_TRANSLATIONS = {
"La regla de formato condicional no puede hacer referencia a una hoja diferente.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'es'},
"La regola di formattazione condizionale non può contenere un riferimento a un altro foglio.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'it'},
"La règle de mise en forme conditionnelle ne doit pas faire référence à une autre feuille.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'fr'},
"Une règle de mise en forme conditionnelle ne peut pas faire référence à une autre feuille.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'fr_ca'},
"Die Regel für eine bedingte Formatierung darf sich nicht auf ein anderes Tabellenblatt beziehen.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'de'},
"Правило условного форматирования не может ссылаться на другой лист.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'ru'},
"조건부 서식 규칙은 다른 시트를 참조할 수 없습니다.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'ko'},
Expand All @@ -540,13 +543,15 @@ ErrorHandler_._ERROR_MESSAGE_TRANSLATIONS = {
"Правило умовного форматування не може посилатися на інший аркуш.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'uk'},
"لا يمكن أن تشير الصيغة الشرطية إلى ورقة مختلفة.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'ar_sa'},
"Ο κανόνας μορφής υπό συνθήκες δεν μπορεί να αναφέρεται σε διαφορετικό φύλλο.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'el'},
"En betinget formateringsregel kan ikke referere til et annet ark.": { ref: NORMALIZED_ERRORS.CONDITIONNAL_RULE_REFERENCE_DIF_SHEET, locale: 'no'},

// "We're sorry, a server error occurred. Please wait a bit and try again."
"We're sorry, a server error occurred. Please wait a bit and try again.": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'en'},
"Spiacenti. Si è verificato un errore del server. Attendi e riprova.": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'it'},
"Une erreur est survenue sur le serveur. Nous vous prions de nous en excuser et vous invitons à réessayer ultérieurement.": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'fr'},
"Xin lỗi bạn, máy chủ đã gặp lỗi. Vui lòng chờ một lát và thử lại.": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'vi'},
"Lo sentimos, se ha producido un error en el servidor. Espera un momento y vuelve a intentarlo.": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'es'},
"Lo sentimos, se produjo un error en el servidor. Aguarde un momento e inténtelo de nuevo.": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'es_419'},
"ขออภัย มีข้อผิดพลาดของเซิร์ฟเวอร์เกิดขึ้น โปรดรอสักครู่แล้วลองอีกครั้ง": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'th'},
"很抱歉,伺服器發生錯誤,請稍後再試。": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'zh_tw'},
"Infelizmente ocorreu um erro do servidor. Espere um momento e tente novamente.": { ref: NORMALIZED_ERRORS.SERVER_ERROR_RETRY_LATER, locale: 'pt'},
Expand Down Expand Up @@ -597,6 +602,7 @@ ErrorHandler_._ERROR_MESSAGE_TRANSLATIONS = {
// "You are trying to edit a protected cell or object. Please contact the spreadsheet owner to remove protection if you need to edit."
"You are trying to edit a protected cell or object. Please contact the spreadsheet owner to remove protection if you need to edit.": { ref: NORMALIZED_ERRORS.TRYING_TO_EDIT_PROTECTED_CELL, locale: 'en'},
"保護されているセルやオブジェクトを編集しようとしています。編集する必要がある場合は、スプレッドシートのオーナーに連絡して保護を解除してもらってください。": { ref: NORMALIZED_ERRORS.TRYING_TO_EDIT_PROTECTED_CELL, locale: 'ja'},
"Estás intentando editar una celda o un objeto protegidos. Ponte en contacto con el propietario de la hoja de cálculo para desprotegerla si es necesario modificarla.": { ref: NORMALIZED_ERRORS.TRYING_TO_EDIT_PROTECTED_CELL, locale: 'es'},

// "Unable to talk to trigger service"
"Unable to talk to trigger service": { ref: NORMALIZED_ERRORS.UNABLE_TO_TALK_TO_TRIGGER_SERVICE, locale: 'en'},
Expand All @@ -616,13 +622,14 @@ ErrorHandler_._ERROR_MESSAGE_TRANSLATIONS = {

// "Invalid to header" - eg: Gmail.Users.Messages.send
"Invalid to header": { ref: NORMALIZED_ERRORS.INVALID_EMAIL, locale: 'en'},

// "Invalid cc header" - eg: Gmail.Users.Messages.send
"Invalid cc header": { ref: NORMALIZED_ERRORS.INVALID_EMAIL, locale: 'en'},

// "Failed to send email: no recipient" - eg: GmailApp.sendEmail()
"Failed to send email: no recipient": { ref: NORMALIZED_ERRORS.NO_RECIPIENT, locale: 'en'},

"Failed to send email: no recipient": { ref: NORMALIZED_ERRORS.NO_RECIPIENT, locale: 'en'},
// "Recipient address required" - eg: Gmail.Users.Messages.send()
"Recipient address required": { ref: NORMALIZED_ERRORS.NO_RECIPIENT, locale: 'en'},

};

/**
Expand Down Expand Up @@ -656,6 +663,17 @@ ErrorHandler_._ERROR_PARTIAL_MATCH = [
variables: ['email'],
ref: NORMALIZED_ERRORS.INVALID_ARGUMENT,
locale: 'en'},

// "A sheet with the name "XXX" already exists. Please enter another name." - eg: [Sheet].setName()
{regex: /^A sheet with the name "([^"]*)" already exists\. Please enter another name\.$/,
variables: ['sheetName'],
ref: NORMALIZED_ERRORS.SHEET_ALREADY_EXISTS_PLEASE_ENTER_ANOTHER_NAME,
locale: 'en'},
{regex: /^Ya existe una hoja con el nombre "([^"]*)"\. Ingresa otro\.$/,
variables: ['sheetName'],
ref: NORMALIZED_ERRORS.SHEET_ALREADY_EXISTS_PLEASE_ENTER_ANOTHER_NAME,
locale: 'es_419'},

];

/**
Expand Down

0 comments on commit ce5b591

Please sign in to comment.