From 0707c98d25713478bf0912477cbeb9f795c9eefe Mon Sep 17 00:00:00 2001 From: Chris Garrity Date: Fri, 22 May 2020 08:11:51 -0400 Subject: [PATCH] More error reporting Provide more details about content and language that caused errors to diagnose translation errors. --- scripts/freshdesk-api.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/freshdesk-api.js b/scripts/freshdesk-api.js index 9e44a12e..03d6fa14 100644 --- a/scripts/freshdesk-api.js +++ b/scripts/freshdesk-api.js @@ -27,6 +27,9 @@ class FreshdeskApi { } let err = new Error(`response ${res.statusText}`); err.code = res.status; + if (res.status === 429) { + err.retryAfter = res.headers.get('Retry-After'); + } throw err; } @@ -79,7 +82,10 @@ class FreshdeskApi { .then(this.checkStatus) .then(res => res.json()); } - // re-raise the error otherwise + if (err.code === 429) { + this.rateLimited = true; + } + process.stdout.write(`Error processing id ${id} for locale ${locale}: ${err.message}\n`); throw err; }); } @@ -149,7 +155,7 @@ class FreshdeskApi { if (err.code === 429) { this.rateLimited = true; } - // re-raise the error otherwise + process.stdout.write(`Error processing id ${id} for locale ${locale}: ${err.message}\n`); throw err; }); }