Skip to content
Snippets Groups Projects
Commit c4b13ebb authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Move try/catch error handling from view file to relays module

parent b2c9308b
No related branches found
No related tags found
1 merge request!59Add try/catch error handling
......@@ -28,15 +28,27 @@ const relays = {
commit('SET_RELAYS', response.data.relays)
commit('SET_LOADING', false)
},
async AddRelay({ commit, getters }, relay) {
async AddRelay({ commit, dispatch, getters }, relay) {
commit('ADD_RELAY', relay)
await addRelay(relay, getters.authHost, getters.token)
try {
await addRelay(relay, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('FetchRelays')
}
},
async DeleteRelay({ commit, getters }, relay) {
async DeleteRelay({ commit, dispatch, getters }, relay) {
commit('DELETE_RELAY', relay)
await deleteRelay(relay, getters.authHost, getters.token)
try {
await deleteRelay(relay, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('FetchRelays')
}
}
}
}
......
......@@ -52,22 +52,10 @@ export default {
},
methods: {
followRelay() {
try {
this.$store.dispatch('AddRelay', this.newRelay)
} catch (_e) {
return
} finally {
this.$store.dispatch('FetchRelays')
}
this.$store.dispatch('AddRelay', this.newRelay)
},
deleteRelay(relay) {
try {
this.$store.dispatch('DeleteRelay', relay)
} catch (_e) {
return
} finally {
this.$store.dispatch('FetchRelays')
}
this.$store.dispatch('DeleteRelay', relay)
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment