Show error if debug log upload fails

This commit is contained in:
Scott Nonnenberg 2018-07-19 10:21:53 -07:00
parent 4ca674edb2
commit 2ef2235317
3 changed files with 31 additions and 11 deletions

View file

@ -417,6 +417,10 @@
"message":
"This log will be posted publicly online for contributors to view. You may examine and edit it before submitting."
},
"debugLogError": {
"message":
"Something went wrong with the upload! Please consider manually adding your log to the bug you file."
},
"reportIssue": {
"message": "Report an issue",
"description": "Link to open the issue tracker"

View file

@ -14,11 +14,18 @@ const USER_AGENT = `Signal Desktop ${VERSION}`;
// https://github.com/sindresorhus/got/pull/466
const submitFormData = (form, url) =>
new Promise((resolve, reject) => {
form.submit(url, error => {
form.submit(url, (error, response) => {
if (error) {
return reject(error);
}
const { statusCode } = response;
if (statusCode !== 204) {
return reject(
new Error(`Failed to upload to S3, got status ${statusCode}`)
);
}
return resolve();
});
});

View file

@ -55,16 +55,25 @@
this.$('.buttons, textarea').remove();
this.$('.result').addClass('loading');
const publishedLogURL = await window.log.publish(text);
const view = new Whisper.DebugLogLinkView({
url: publishedLogURL,
el: this.$('.result'),
});
this.$('.loading').removeClass('loading');
view.render();
this.$('.link')
.focus()
.select();
try {
const publishedLogURL = await window.log.publish(text);
const view = new Whisper.DebugLogLinkView({
url: publishedLogURL,
el: this.$('.result'),
});
this.$('.loading').removeClass('loading');
view.render();
this.$('.link')
.focus()
.select();
} catch (error) {
console.log(
'DebugLogView error:',
error && error.stack ? error.stack : error
);
this.$('.loading').removeClass('loading');
this.$('.result').text(i18n('debugLogError'));
}
},
});
})();