Skip to content

Commit

Permalink
Debug Logs: Log response body when we fail to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Feb 22, 2021
1 parent 3306c82 commit b35f0f0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions ts/logging/debuglogs.ts
Expand Up @@ -4,7 +4,7 @@
import FormData from 'form-data';
import { gzip } from 'zlib';
import pify from 'pify';
import got from 'got';
import got, { Response } from 'got';
import { getUserAgent } from '../util/getUserAgent';

const BASE_URL = 'https://debuglogs.org';
Expand Down Expand Up @@ -68,9 +68,18 @@ export const uploadDebugLogs = async (
});

window.log.info('Debug log upload starting...');
const { statusCode } = await got.post(url, { headers, body: form });
if (statusCode !== 204) {
throw new Error(`Failed to upload to S3, got status ${statusCode}`);
try {
const { statusCode, body } = await got.post(url, { headers, body: form });
if (statusCode !== 204) {
throw new Error(
`Failed to upload to S3, got status ${statusCode}, body '${body}'`
);
}
} catch (error) {
const response = error.response as Response<string>;
throw new Error(
`Got threw on upload to S3, got status ${response?.statusCode}, body '${response?.body}' `
);
}
window.log.info('Debug log upload complete.');

Expand Down

0 comments on commit b35f0f0

Please sign in to comment.