1
0

feat: don't rethrow same error and handle errors globally

This commit is contained in:
Dominik Pschenitschni
2021-10-09 16:04:19 +02:00
parent 6f51921588
commit 3b940cb56c
71 changed files with 69 additions and 451 deletions

View File

@ -100,7 +100,6 @@ export default {
this.$store.dispatch('namespaces/loadNamespaces')
this.$router.push({name: 'list.index', params: {listId: r.getListId()}})
})
.catch(e => this.$message.error(e))
},
},
}

View File

@ -35,7 +35,6 @@ export default {
this.$message.success({message: this.$t('filters.delete.success')})
this.$router.push({name: 'namespaces.index'})
})
.catch(e => this.$message.error(e))
},
},
}

View File

@ -105,7 +105,6 @@ export default {
this.filter = r
this.filters = objectToSnakeCase(this.filter.filters)
})
.catch(e => this.$message.error(e))
},
save() {
this.filter.filters = this.filters
@ -117,7 +116,6 @@ export default {
this.filters = objectToSnakeCase(this.filter.filters)
this.$router.back()
})
.catch(e => this.$message.error(e))
},
},
}

View File

@ -133,27 +133,18 @@ export default {
methods: {
loadLabels() {
this.$store.dispatch('labels/loadAllLabels')
.catch(e => {
this.$message.error(e)
})
},
deleteLabel(label) {
this.$store.dispatch('labels/deleteLabel', label)
.then(() => {
this.$message.success({message: this.$t('label.deleteSuccess')})
})
.catch(e => {
this.$message.error(e)
})
},
editLabelSubmit() {
this.$store.dispatch('labels/updateLabel', this.labelEditLabel)
.then(() => {
this.$message.success({message: this.$t('label.edit.success')})
})
.catch(e => {
this.$message.error(e)
})
},
editLabel(label) {
if (label.createdBy.id !== this.userInfo.id) {

View File

@ -75,9 +75,6 @@ export default {
})
this.$message.success({message: this.$t('label.create.success')})
})
.catch((e) => {
this.$message.error(e)
})
},
},
}

View File

@ -71,9 +71,6 @@ export default {
params: { listId: r.id },
})
})
.catch((e) => {
this.$message.error(e)
})
},
},
}

View File

@ -144,9 +144,6 @@ export default {
this.$store.dispatch(CURRENT_LIST, r)
this.setTitle(this.getListTitle(r))
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.listLoaded = this.$route.params.listId
})

View File

@ -42,9 +42,6 @@ export default {
this.$store.commit('namespaces/setListInNamespaceById', r)
this.$message.success({message: this.$t('list.archive.success')})
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.$router.back()
})

View File

@ -128,9 +128,6 @@ export default {
})
})
})
.catch(e => {
this.$message.error(e)
})
}, 300)
},
setBackground(backgroundId) {
@ -145,9 +142,6 @@ export default {
this.$store.commit('namespaces/setListInNamespaceById', l)
this.$message.success({message: this.$t('list.background.success')})
})
.catch(e => {
this.$message.error(e)
})
},
uploadBackground() {
if (this.$refs.backgroundUploadInput.files.length === 0) {
@ -160,9 +154,6 @@ export default {
this.$store.commit('namespaces/setListInNamespaceById', l)
this.$message.success({message: this.$t('list.background.success')})
})
.catch(e => {
this.$message.error(e)
})
},
removeBackground() {
this.listService.removeBackground(this.currentList)
@ -172,9 +163,6 @@ export default {
this.$message.success({message: this.$t('list.background.removeSuccess')})
this.$router.back()
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -30,9 +30,6 @@ export default {
this.$message.success({message: this.$t('list.delete.success')})
this.$router.push({name: 'home'})
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -50,9 +50,6 @@ export default {
this.$message.success({message: this.$t('list.duplicate.success')})
this.$router.push({name: 'list.index', params: {listId: r.list.id}})
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -101,9 +101,6 @@ export default {
.then(r => {
this.list = { ...r }
})
.catch(e => {
this.$message.error(e)
})
},
save() {
this.$store.dispatch('lists/updateList', this.list)
@ -113,9 +110,6 @@ export default {
this.$message.success({message: this.$t('list.edit.success')})
this.$router.back()
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -68,9 +68,6 @@ export default {
this.manageUsersComponent = 'userTeam'
this.setTitle(this.$t('list.share.title', {list: this.list.title}))
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -565,7 +565,6 @@ export default {
}
this.$store.dispatch('kanban/updateBucket', newBucket)
.then(() => this.$message.success({message: this.$t('list.kanban.doneBucketSavedSuccess')}))
.catch(e => this.$message.error(e))
},
collapseBucket(bucket) {
this.collapsedBuckets[bucket.id] = true

View File

@ -307,9 +307,6 @@ export default {
.then(r => {
this.tasks[e.newIndex] = r
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -77,9 +77,6 @@ export default {
this.$message.success({message: this.$t('namespace.create.success') })
this.$router.back()
})
.catch((e) => {
this.$message.error(e)
})
},
},
}

View File

@ -40,9 +40,6 @@ export default {
this.$store.commit('namespaces/setNamespaceById', r)
this.$message.success({message: this.$t('namespace.archive.success')})
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.$router.back()
})

View File

@ -41,9 +41,6 @@ export default {
this.$message.success({message: this.$t('namespace.delete.success')})
this.$router.push({name: 'home'})
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -112,9 +112,6 @@ export default {
this.title = this.$t('namespace.edit.title', {namespace: r.title})
this.setTitle(this.title)
})
.catch(e => {
this.$message.error(e)
})
},
save() {
this.namespaceService.update(this.namespace)
@ -124,9 +121,6 @@ export default {
this.$message.success({message: this.$t('namespace.edit.success')})
this.$router.back()
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -68,9 +68,6 @@ export default {
this.title = this.$t('namespace.share.title', { namespace: this.namespace.title })
this.setTitle(this.title)
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -211,9 +211,6 @@ export default {
this.tasks = tasks
})
.catch(e => {
this.$message.error(e)
})
},
updateTasks(updatedTask) {
for (const t in this.tasks) {

View File

@ -574,9 +574,6 @@ export default {
this.setActiveFields()
this.setTitle(this.task.title)
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.$nextTick(() => this.visible = true)
this.scrollToHeading()
@ -620,25 +617,21 @@ export default {
this.task.endDate = this.task.dueDate
}
try {
this.task = await this.$store.dispatch('tasks/update', this.task)
this.setActiveFields()
this.task = await this.$store.dispatch('tasks/update', this.task)
this.setActiveFields()
if (!showNotification) {
return
}
let actions = []
if (undoCallback !== null) {
actions = [{
title: 'Undo',
callback: undoCallback,
}]
}
this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions)
} catch(e) {
this.$message.error(e)
if (!showNotification) {
return
}
let actions = []
if (undoCallback !== null) {
actions = [{
title: 'Undo',
callback: undoCallback,
}]
}
this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions)
},
setFieldActive(fieldName) {
this.activeFields[fieldName] = true
@ -664,9 +657,6 @@ export default {
this.$message.success({message: this.$t('task.detail.deleteSuccess')})
this.$router.push({name: 'list.index', params: {listId: this.task.listId}})
})
.catch(e => {
this.$message.error(e)
})
},
toggleTaskDone() {
this.task.done = !this.task.done
@ -705,9 +695,6 @@ export default {
this.task = t
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -229,9 +229,6 @@ export default {
this.title = this.$t('team.edit.title', {team: this.team.name})
this.setTitle(this.title)
})
.catch((e) => {
this.$message.error(e)
})
},
save() {
if (this.team.name === '') {
@ -246,9 +243,6 @@ export default {
this.team = response
this.$message.success({message: this.$t('team.edit.success')})
})
.catch((e) => {
this.$message.error(e)
})
},
deleteTeam() {
this.teamService
@ -257,9 +251,6 @@ export default {
this.$message.success({message: this.$t('team.edit.delete.success')})
this.$router.push({name: 'teams.index'})
})
.catch((e) => {
this.$message.error(e)
})
},
deleteUser() {
this.teamMemberService
@ -268,9 +259,6 @@ export default {
this.$message.success({message: this.$t('team.edit.deleteUser.success')})
this.loadTeam()
})
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.showUserDeleteModal = false
})
@ -286,9 +274,6 @@ export default {
this.loadTeam()
this.$message.success({message: this.$t('team.edit.userAddedSuccess')})
})
.catch((e) => {
this.$message.error(e)
})
},
toggleUserType(member) {
member.admin = !member.admin
@ -308,9 +293,6 @@ export default {
this.$t('team.edit.madeMember'),
})
})
.catch((e) => {
this.$message.error(e)
})
},
findUser(query) {
if (query === '') {
@ -323,9 +305,6 @@ export default {
.then((response) => {
this.foundUsers = response
})
.catch((e) => {
this.$message.error(e)
})
},
clearAll() {
this.foundUsers = []

View File

@ -48,9 +48,6 @@ export default {
.then(response => {
this.teams = response
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -65,9 +65,6 @@ export default {
})
this.$message.success({message: this.$t('team.create.success') })
})
.catch((e) => {
this.$message.error(e)
})
},
},
}

View File

@ -57,7 +57,6 @@ export default {
}
this.dataExportService.download(this.password)
.catch(e => this.$message.error(e))
},
},
}

View File

@ -147,7 +147,6 @@ export default {
}
this.$store.dispatch('auth/register', credentials)
.catch(() => {})
},
},
}

View File

@ -395,14 +395,12 @@ export default {
.then(() => {
this.$message.success({message: this.$t('user.settings.passwordUpdateSuccess')})
})
.catch(e => this.$message.error(e))
},
updateEmail() {
this.emailUpdateService.update(this.emailUpdate)
.then(() => {
this.$message.success({message: this.$t('user.settings.updateEmailSuccess')})
})
.catch(e => this.$message.error(e))
},
totpStatus() {
if (!this.totpEnabled) {
@ -420,7 +418,7 @@ export default {
return
}
this.$message.error(e)
throw e
})
},
totpSetQrCode() {
@ -437,7 +435,6 @@ export default {
this.totp = r
this.totpSetQrCode()
})
.catch(e => this.$message.error(e))
},
totpConfirm() {
this.totpService.enable({passcode: this.totpConfirmPasscode})
@ -445,7 +442,6 @@ export default {
this.totp.enabled = true
this.$message.success({message: this.$t('user.settings.totp.confirmSuccess')})
})
.catch(e => this.$message.error(e))
},
totpDisable() {
this.totpService.disable({password: this.totpDisablePassword})
@ -454,7 +450,6 @@ export default {
this.totp = new TotpModel()
this.$message.success({message: this.$t('user.settings.totp.disableSuccess')})
})
.catch(e => this.$message.error(e))
},
updateSettings() {
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
@ -467,7 +462,6 @@ export default {
this.$store.commit('auth/setUserSettings', this.settings)
this.$message.success({message: this.$t('user.settings.general.savedSuccess')})
})
.catch(e => this.$message.error(e))
},
anchorHashCheck() {
if (window.location.hash === this.$route.hash) {