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

@ -128,9 +128,6 @@ export default {
},
loadLabels() {
this.$store.dispatch('labels/loadAllLabels')
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -218,7 +218,6 @@ export default {
return
}
this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.$message.error(e))
},
resize() {
// Hide the menu by default on mobile
@ -263,9 +262,6 @@ export default {
...list,
position,
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.listUpdating[list.id] = false
})

View File

@ -483,7 +483,6 @@ export default {
.then(r => {
this[kind] = r
})
.catch(e => this.$message.error(e))
}
},
setDoneFilter() {
@ -535,9 +534,6 @@ export default {
// Filter users from the results who are already assigned
this[`found${kind}`] = response.filter(({id}) => !includesById(this[kind], id))
})
.catch(e => {
this.$message.error(e)
})
},
add(kind, filterName) {
this.$nextTick(() => {

View File

@ -68,9 +68,6 @@ export default {
.then(b => {
this.background = b
})
.catch(e => {
this.$message.error(e)
})
.finally(() => this.backgroundLoading = false)
},
toggleFavoriteList(list) {
@ -80,7 +77,6 @@ export default {
return
}
this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.$message.error(e))
},
},
}

View File

@ -138,9 +138,6 @@ export default {
}
this.migrate()
})
.catch(e => {
this.$message.error(e)
})
}
},
methods: {
@ -149,9 +146,6 @@ export default {
.then(r => {
this.authUrl = r.url
})
.catch(e => {
this.$message.error(e)
})
},
migrate() {
this.isMigrating = true
@ -167,9 +161,6 @@ export default {
this.message = r.message
this.$store.dispatch('namespaces/loadNamespaces')
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.isMigrating = false
})
@ -184,9 +175,6 @@ export default {
this.message = r.message
this.$store.dispatch('namespaces/loadNamespaces')
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.isMigrating = false
})

View File

@ -99,9 +99,6 @@ export default {
this.$emit('change', subscription)
this.$message.success({message: this.$t('task.subscription.subscribeSuccess', {entity: this.entity})})
})
.catch(e => {
this.$message.error(e)
})
},
unsubscribe() {
const subscription = new SubscriptionModel({
@ -113,9 +110,6 @@ export default {
this.$emit('change', null)
this.$message.success({message: this.$t('task.subscription.unsubscribeSuccess', {entity: this.entity})})
})
.catch(e => {
this.$message.error(e)
})
},
},
}

View File

@ -98,9 +98,6 @@ export default {
.then(r => {
this.allNotifications = r
})
.catch(e => {
this.$message.error(e)
})
},
to(n, index) {
const to = {
@ -137,7 +134,6 @@ export default {
.then(r => {
this.allNotifications[index] = r
})
.catch(e => this.$message.error(e))
}
},
},

View File

@ -392,9 +392,6 @@ export default {
this.$router.push({name: 'task.detail', params: {id: r.id}})
this.closeQuickActions()
})
.catch((e) => {
this.$message.error(e)
})
},
newList() {
if (this.currentList === null) {
@ -411,9 +408,6 @@ export default {
this.$router.push({name: 'list.index', params: {listId: r.id}})
this.closeQuickActions()
})
.catch((e) => {
this.$message.error(e)
})
},
newNamespace() {
const newNamespace = new NamespaceModel({title: this.query})
@ -423,9 +417,6 @@ export default {
this.$message.success({message: this.$t('namespace.create.success')})
this.closeQuickActions()
})
.catch((e) => {
this.$message.error(e)
})
},
newTeam() {
const newTeam = new TeamModel({name: this.query})
@ -438,9 +429,6 @@ export default {
this.$message.success({message: this.$t('team.create.success')})
this.closeQuickActions()
})
.catch((e) => {
this.$message.error(e)
})
},
select(parentIndex, index) {

View File

@ -226,9 +226,6 @@ export default {
.then((r) => {
this.linkShares = r
})
.catch((e) => {
this.$message.error(e)
})
},
add(listId) {
const newLinkShare = new LinkShareModel({
@ -247,9 +244,6 @@ export default {
this.$message.success({message: this.$t('list.share.links.createSuccess')})
this.load(listId)
})
.catch((e) => {
this.$message.error(e)
})
},
remove(listId) {
const linkshare = new LinkShareModel({
@ -262,9 +256,6 @@ export default {
this.$message.success({message: this.$t('list.share.links.deleteSuccess')})
this.load(listId)
})
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
})

View File

@ -281,9 +281,6 @@ export default {
this.selectedRight[s.id] = s.right,
)
})
.catch((e) => {
this.$message.error(e)
})
},
deleteSharable() {
if (this.shareType === 'user') {
@ -306,9 +303,6 @@ export default {
}
this.$message.success({message: this.$t('list.share.userTeam.removeSuccess', {type: this.shareTypeName, sharable: this.sharableName})})
})
.catch((e) => {
this.$message.error(e)
})
},
add(admin) {
if (admin === null) {
@ -331,9 +325,6 @@ export default {
this.$message.success({message: this.$t('list.share.userTeam.addedSuccess', {type: this.shareTypeName})})
this.load()
})
.catch((e) => {
this.$message.error(e)
})
},
toggleType(sharable) {
if (
@ -367,9 +358,6 @@ export default {
}
this.$message.success({message: this.$t('list.share.userTeam.updatedSuccess', {type: this.shareTypeName})})
})
.catch((e) => {
this.$message.error(e)
})
},
find(query) {
if (query === '') {
@ -382,9 +370,6 @@ export default {
.then((response) => {
this.found = response
})
.catch((e) => {
this.$message.error(e)
})
},
clearAll() {
this.found = []

View File

@ -113,16 +113,16 @@ export default {
)
})
Promise.all(newTasks)
return Promise.all(newTasks)
.then(() => {
this.newTaskTitle = ''
})
.catch(e => {
if (e === 'NO_LIST') {
if (e.message === 'NO_LIST') {
this.errorMessage = this.$t('list.create.addListRequired')
return
}
this.$message.error(e)
throw e
})
},
handleEnter(e) {

View File

@ -142,9 +142,6 @@ export default {
this.initTaskFields()
this.$message.success({message: this.$t('task.detail.updateSuccess')})
})
.catch((e) => {
this.$message.error(e)
})
},
},
}

View File

@ -317,9 +317,6 @@ export default {
return tasks
}
})
.catch((e) => {
return Promise.reject(e)
})
}
getAllTasks()
@ -343,9 +340,6 @@ export default {
return 0
})
})
.catch((e) => {
this.$message.error(e)
})
},
addGantAttributes(t) {
if (typeof t.durationDays !== 'undefined' && typeof t.offsetDays !== 'undefined') {
@ -423,9 +417,6 @@ export default {
}
}
})
.catch((e) => {
this.$message.error(e)
})
},
editTask(task) {
this.taskToEdit = task
@ -460,9 +451,6 @@ export default {
this.newTaskTitle = ''
this.hideCrateNewTask()
})
.catch((e) => {
this.$message.error(e)
})
},
formatYear(date) {
return this.format(date, 'MMMM, yyyy')

View File

@ -84,9 +84,6 @@ export default {
this.loadedList = JSON.parse(JSON.stringify(currentList))
})
.catch(e => {
this.$message.error(e)
})
},
loadTasksForPage(e) {

View File

@ -228,9 +228,6 @@ export default {
)
this.$message.success(r)
})
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
})

View File

@ -227,9 +227,6 @@ export default {
this.comments = r
this.makeActions()
})
.catch((e) => {
this.$message.error(e)
})
},
addComment() {
if (this.newComment.comment === '') {
@ -253,9 +250,6 @@ export default {
this.$message.success({message: this.$t('task.comment.addedSuccess')})
this.makeActions()
})
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.creating = false
})
@ -289,9 +283,6 @@ export default {
this.saved = null
}, 2000)
})
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.isCommentEdit = false
this.saving = null
@ -307,9 +298,6 @@ export default {
}
}
})
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
})

View File

@ -129,9 +129,6 @@ export default {
this.task = r
this.$emit('update:modelValue', r)
})
.catch((e) => {
this.$message.error(e)
})
},
},
}

View File

@ -83,9 +83,6 @@ export default {
this.saved = false
}, 2000)
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.saving = false
})

View File

@ -84,9 +84,6 @@ export default {
this.$emit('update:modelValue', this.assignees)
this.$message.success({message: this.$t('task.assignee.assignSuccess')})
})
.catch(e => {
this.$message.error(e)
})
},
removeAssignee(user) {
this.$store.dispatch('tasks/removeAssignee', {user: user, taskId: this.taskId})
@ -99,9 +96,6 @@ export default {
}
this.$message.success({message: this.$t('task.assignee.unassignSuccess')})
})
.catch(e => {
this.$message.error(e)
})
},
findUser(query) {
if (query === '') {
@ -114,9 +108,6 @@ export default {
// Filter the results to not include users who are already assigned
this.foundUsers = response.filter(({id}) => !includesById(this.assignees, id))
})
.catch(e => {
this.$message.error(e)
})
},
clearAllFoundUsers() {
this.foundUsers = []

View File

@ -111,9 +111,6 @@ export default {
this.$message.success({message: this.$t('task.label.addSuccess')})
}
})
.catch(e => {
this.$message.error(e)
})
},
removeLabel(label) {
const removeFromState = () => {
@ -136,9 +133,6 @@ export default {
removeFromState()
this.$message.success({message: this.$t('task.label.removeSuccess')})
})
.catch(e => {
this.$message.error(e)
})
},
createAndAddLabel(title) {
if (this.taskId === 0) {
@ -152,9 +146,6 @@ export default {
this.labels.push(r)
this.$message.success({message: this.$t('task.label.addCreateSuccess')})
})
.catch(e => {
this.$message.error(e)
})
},
},

View File

@ -82,9 +82,6 @@ export default {
this.showSavedMessage = false
}, 2000)
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.saving = false
})

View File

@ -104,9 +104,6 @@ export default {
playPop()
}
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.loadingInternal = false
})

View File

@ -60,9 +60,6 @@ export default {
.then(response => {
this.foundLists = response
})
.catch(e => {
this.$message.error(e)
})
},
clearAll() {
this.foundLists = []

View File

@ -185,14 +185,8 @@ export default {
},
},
methods: {
findTasks(query) {
this.taskService.getAll({}, {s: query})
.then(response => {
this.foundTasks = response
})
.catch(e => {
this.$message.error(e)
})
async findTasks(query) {
this.foundTasks = await this.taskService.getAll({}, {s: query})
},
addTaskRelation() {
let rel = new TaskRelationModel({
@ -213,9 +207,6 @@ export default {
this.saved = false
}, 2000)
})
.catch(e => {
this.$message.error(e)
})
},
removeTaskRelation() {
const rel = new TaskRelationModel({
@ -237,9 +228,6 @@ export default {
this.saved = false
}, 2000)
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
})
@ -251,9 +239,6 @@ export default {
this.newTaskRelationTask = r
this.addTaskRelation()
})
.catch(e => {
this.$message.error(e)
})
},
relationKindTitle(kind, length) {
return this.$tc(`task.relation.kinds.${kind}`, length)

View File

@ -187,9 +187,6 @@ export default {
},
}])
})
.catch(e => {
this.$message.error(e)
})
}
if (checked) {
@ -206,9 +203,6 @@ export default {
this.$emit('task-updated', t)
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
})
.catch(e => {
this.$message.error(e)
})
},
hideDeferDueDatePopup(e) {
if (this.showDefer) {

View File

@ -87,12 +87,9 @@ export default {
Cropper,
},
methods: {
avatarStatus() {
this.avatarService.get({})
.then(r => {
this.avatarProvider = r.avatarProvider
})
.catch(e => this.$message.error(e))
async avatarStatus() {
const { avatarProvider } = await this.avatarService.get({})
this.avatarProvider = avatarProvider
},
updateAvatarStatus() {
const avatarStatus = new AvatarModel({avatarProvider: this.avatarProvider})
@ -101,7 +98,6 @@ export default {
this.$message.success({message: this.$t('user.settings.avatar.statusUpdateSuccess')})
this.$store.commit('auth/reloadAvatar')
})
.catch(e => this.$message.error(e))
},
uploadAvatar() {
this.loading = true
@ -114,7 +110,6 @@ export default {
this.$message.success({message: this.$t('user.settings.avatar.setSuccess')})
this.$store.commit('auth/reloadAvatar')
})
.catch(e => this.$message.error(e))
.finally(() => {
this.loading = false
this.isCropAvatar = false

View File

@ -64,7 +64,6 @@ export default {
this.$message.success({message: this.$t('user.export.success')})
this.password = ''
})
.catch(e => this.$message.error(e))
},
},
}

View File

@ -113,7 +113,6 @@ export default {
this.$message.success({message: this.$t('user.deletion.requestSuccess')})
this.password = ''
})
.catch(e => this.$message.error(e))
},
cancelDeletion() {
if (this.password === '') {
@ -128,7 +127,6 @@ export default {
this.$store.dispatch('auth/refreshUserInfo')
this.password = ''
})
.catch(e => this.$message.error(e))
},
},
}