Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote error categories to error #534

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/actions/google/drive/sheets/google_sheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class GoogleSheetsAction extends GoogleDriveAction {
}
} catch (e: any) {
this.sanitizeGaxiosError(e)
winston.debug(`Failed execute for Google Sheets. Error: ${e.toString()}`,
winston.error(`Failed execute for Google Sheets. Error: ${e.toString()}`,
{webhookId: request.webhookId})
resp.success = false
resp.message = e.toString()
Expand Down Expand Up @@ -127,7 +127,7 @@ export class GoogleSheetsAction extends GoogleDriveAction {

const files = await drive.files.list(options).catch((e: any) => {
this.sanitizeGaxiosError(e)
winston.debug(`Error listing drives. Error ${e.toString()}`,
winston.error(`Error listing drives. Error ${e.toString()}`,
{webhookId: request.webhookId})
throw e
})
Expand All @@ -144,7 +144,7 @@ export class GoogleSheetsAction extends GoogleDriveAction {
const sheets = await this.retriableSpreadsheetGet(spreadsheetId, sheet,
0, request.webhookId!).catch((e: any) => {
this.sanitizeGaxiosError(e)
winston.debug(`Error retrieving spreadsheet. Error ${e.toString()}`,
winston.error(`Error retrieving spreadsheet. Error ${e.toString()}`,
{webhookId: request.webhookId})
throw e
})
Expand Down Expand Up @@ -215,13 +215,13 @@ export class GoogleSheetsAction extends GoogleDriveAction {
}
this.resize(maxRows, sheet, spreadsheetId, sheetId).catch((e: any) => {
this.sanitizeGaxiosError(e)
winston.debug(e.toString(), {webhookId: request.webhookId})
winston.error(e.toString(), {webhookId: request.webhookId})
throw e
})
}
this.flush(requestCopy, sheet, spreadsheetId, request.webhookId!).catch((e: any) => {
this.sanitizeGaxiosError(e)
winston.debug(e, {webhookId: request.webhookId})
winston.error(e, {webhookId: request.webhookId})
throw e
})
}
Expand All @@ -243,7 +243,7 @@ export class GoogleSheetsAction extends GoogleDriveAction {
}
this.resize(maxRows, sheet, spreadsheetId, sheetId).catch((e: any) => {
this.sanitizeGaxiosError(e)
winston.debug(`Resize failed: rowCount: ${maxRows}`, request.webhookId)
winston.error(`Resize failed: rowCount: ${maxRows}`, request.webhookId)
throw e
})
}
Expand Down Expand Up @@ -325,7 +325,7 @@ export class GoogleSheetsAction extends GoogleDriveAction {
attempt: number, webhookId: string): Promise<any> {
return await sheet.spreadsheets.get({spreadsheetId}).catch(async (e: any) => {
this.sanitizeGaxiosError(e)
winston.debug(`SpreadsheetG error: ${e}`, {webhookId})
winston.error(`SpreadsheetG error: ${e}`, {webhookId})
if (e.code === 429 && process.env.GOOGLE_SHEET_RETRY && attempt <= MAX_RETRY_COUNT) {
winston.warn("Queueing retry", {webhookId})
await this.delay((3 ** (attempt + 1)) * 1000)
Expand All @@ -340,7 +340,7 @@ export class GoogleSheetsAction extends GoogleDriveAction {
sheet: Sheet, spreadsheetId: string, webhookId: string) {
return sheet.spreadsheets.batchUpdate({ spreadsheetId, requestBody: buffer}).catch(async (e: any) => {
this.sanitizeGaxiosError(e)
winston.debug(`Flush error: ${e}`, {webhookId})
winston.error(`Flush error: ${e}`, {webhookId})
if (e.code === 429 && process.env.GOOGLE_SHEET_RETRY) {
winston.warn("Queueing retry", {webhookId})
return this.flushRetry(buffer, sheet, spreadsheetId)
Expand All @@ -362,7 +362,7 @@ export class GoogleSheetsAction extends GoogleDriveAction {
this.sanitizeGaxiosError(e)
retrySuccess = false
if (e.code === 429) {
winston.debug(`Retry number ${retryCount} failed`)
winston.error(`Retry number ${retryCount} failed`)
winston.debug(e)
} else {
throw e
Expand Down