Show network and server errors in a toast 🍞 notification
gr-error-manager is introduced to deal with error events
fired from gr-rest-api-interface. Currently it will display
the first error it sees for 5 seconds, ignoring others during
that time. If a response comes back as a 403, it prompts the
user to refresh the page and the alert remains on the screen
indefinitely.
Bug: Issue 3992
Bug: Issue 3953
Change-Id: I4a54eb1e865b88f9a5531e864e0b1d58d638a4cd
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js
index b39295a..ded5108 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.js
@@ -74,13 +74,8 @@
this.disabled = true;
this._xhrPromise = this._saveDraft(this.comment).then(function(response) {
this.disabled = false;
- if (!response.ok) {
- alert('Your draft couldn’t be saved. Check the console and contact ' +
- 'the PolyGerrit team for assistance.');
- return response.text().then(function(text) {
- console.error(text);
- });
- }
+ if (!response.ok) { return response; }
+
return this.$.restAPI.getResponseObject(response).then(function(obj) {
var comment = obj;
comment.__draft = true;
@@ -95,10 +90,8 @@
return obj;
}.bind(this));
}.bind(this)).catch(function(err) {
- alert('Your draft couldn’t be saved. Check the console and contact ' +
- 'the PolyGerrit team for assistance.');
this.disabled = false;
- console.error(err.message);
+ throw err;
}.bind(this));
},
@@ -198,18 +191,12 @@
this._xhrPromise =
this._deleteDraft(this.comment).then(function(response) {
this.disabled = false;
- if (!response.ok) {
- alert('Your draft couldn’t be deleted. Check the console and ' +
- 'contact the PolyGerrit team for assistance.');
- return response.text().then(function(text) {
- console.error(text);
- });
- }
+ if (!response.ok) { return response; }
+
this.fire('comment-discard');
}.bind(this)).catch(function(err) {
- alert('Your draft couldn’t be deleted. Check the console and contact ' +
- 'the PolyGerrit team for assistance.');
this.disabled = false;
+ throw err;
}.bind(this));;
},