Improve error handling

This commit is contained in:
syuilo 2018-08-06 21:48:23 +09:00
parent 99f4ab7000
commit 4260ec713f
1 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,11 @@ export default async (job: bq.Job, done: any): Promise<void> => {
await request(job.data.user, job.data.to, job.data.content);
done();
} catch (res) {
if (!res.hasOwnProperty('statusCode')) {
console.warn(`deliver failed (unknown): ${res}`);
return done();
}
if (res.statusCode == null) return done();
if (res.statusCode >= 400 && res.statusCode < 500) {
// HTTPステータスコード4xxはクライアントエラーであり、それはつまり