Debug Logs: Log response body when we fail to upload
This commit is contained in:
parent
3306c82992
commit
b35f0f0d5c
1 changed files with 13 additions and 4 deletions
|
@ -4,7 +4,7 @@
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
import { gzip } from 'zlib';
|
import { gzip } from 'zlib';
|
||||||
import pify from 'pify';
|
import pify from 'pify';
|
||||||
import got from 'got';
|
import got, { Response } from 'got';
|
||||||
import { getUserAgent } from '../util/getUserAgent';
|
import { getUserAgent } from '../util/getUserAgent';
|
||||||
|
|
||||||
const BASE_URL = 'https://debuglogs.org';
|
const BASE_URL = 'https://debuglogs.org';
|
||||||
|
@ -68,9 +68,18 @@ export const uploadDebugLogs = async (
|
||||||
});
|
});
|
||||||
|
|
||||||
window.log.info('Debug log upload starting...');
|
window.log.info('Debug log upload starting...');
|
||||||
const { statusCode } = await got.post(url, { headers, body: form });
|
try {
|
||||||
if (statusCode !== 204) {
|
const { statusCode, body } = await got.post(url, { headers, body: form });
|
||||||
throw new Error(`Failed to upload to S3, got status ${statusCode}`);
|
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.');
|
window.log.info('Debug log upload complete.');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue