mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-13 01:38:45 +00:00
added try catch, added snackbar notification for errors returned (#10370)
* added try catch, added snackbar notification for errors returned * moved lines into try block
This commit is contained in:
parent
79087b27d3
commit
614848d60b
1 changed files with 16 additions and 4 deletions
|
|
@ -935,10 +935,22 @@
|
|||
}
|
||||
},
|
||||
async feedAction (petKey, foodKey) {
|
||||
const result = await this.$store.dispatch('common:feed', {pet: petKey, food: foodKey});
|
||||
if (result.message) this.text(result.message);
|
||||
if (this.user.preferences.suppressModals.raisePet) return;
|
||||
if (this.user.items.pets[petKey] === -1) this.$root.$emit('habitica::mount-raised', petKey);
|
||||
try {
|
||||
const result = await this.$store.dispatch('common:feed', {pet: petKey, food: foodKey});
|
||||
|
||||
if (result.message) this.text(result.message);
|
||||
if (this.user.preferences.suppressModals.raisePet) return;
|
||||
if (this.user.items.pets[petKey] === -1) this.$root.$emit('habitica::mount-raised', petKey);
|
||||
} catch (e) {
|
||||
const errorMessage = e.message || e;
|
||||
|
||||
this.$store.dispatch('snackbars:add', {
|
||||
title: 'Habitica',
|
||||
text: errorMessage,
|
||||
type: 'error',
|
||||
timeout: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
closeHatchPetDialog () {
|
||||
this.$root.$emit('bv::hide::modal', 'hatching-modal');
|
||||
|
|
|
|||
Loading…
Reference in a new issue