mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-22 15:08:07 +00:00
Catch error responses from API
This commit is contained in:
parent
3a7717e22f
commit
e3ab5afcbd
1 changed files with 7 additions and 2 deletions
|
@ -74,11 +74,16 @@ let StatusCache = new class {
|
||||||
BookWyrm.addRemoveClass(form, 'is-processing', false);
|
BookWyrm.addRemoveClass(form, 'is-processing', false);
|
||||||
trigger.removeAttribute('disabled');
|
trigger.removeAttribute('disabled');
|
||||||
})
|
})
|
||||||
.then(this.submitStatusSuccess.bind(this, form))
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
|
this.submitStatusSuccess(form);
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// @todo Display a notification in the UI instead.
|
// @todo Display a notification in the UI instead.
|
||||||
// For now, the absence of change will be enough.
|
// For now, the absence of change will be enough.
|
||||||
console.warn('Request failed:', error);
|
console.log('Request failed:', error);
|
||||||
|
|
||||||
BookWyrm.addRemoveClass(form, 'has-error', form.className.indexOf('is-hidden') == -1);
|
BookWyrm.addRemoveClass(form, 'has-error', form.className.indexOf('is-hidden') == -1);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue