More error reporting

Provide more details about content and language that caused errors to diagnose translation errors.
This commit is contained in:
Chris Garrity 2020-05-22 08:11:51 -04:00
parent d094f9c2e7
commit 0707c98d25

View file

@ -27,6 +27,9 @@ class FreshdeskApi {
} }
let err = new Error(`response ${res.statusText}`); let err = new Error(`response ${res.statusText}`);
err.code = res.status; err.code = res.status;
if (res.status === 429) {
err.retryAfter = res.headers.get('Retry-After');
}
throw err; throw err;
} }
@ -79,7 +82,10 @@ class FreshdeskApi {
.then(this.checkStatus) .then(this.checkStatus)
.then(res => res.json()); .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; throw err;
}); });
} }
@ -149,7 +155,7 @@ class FreshdeskApi {
if (err.code === 429) { if (err.code === 429) {
this.rateLimited = true; this.rateLimited = true;
} }
// re-raise the error otherwise process.stdout.write(`Error processing id ${id} for locale ${locale}: ${err.message}\n`);
throw err; throw err;
}); });
} }