use try/catch

Signed-off-by: Jakob <jakob.roehrl@web.de>
This commit is contained in:
Jakob
2019-10-09 12:45:33 +02:00
parent 71e7c98fd6
commit 1c2c700593
3 changed files with 18 additions and 28 deletions

View File

@@ -131,19 +131,18 @@ export default {
})
actions.push({
action: async () => {
action: async() => {
this.hideMenu()
this.loading = true
try {
const newBoard = await this.$store.dispatch('cloneBoard', this.board)
this.loading = false
const route = this.routeTo
route.params.id = newBoard.id
this.$router.push(route)
}
catch {
} catch (e) {
OC.Notification.showTemporary(t('deck', 'An error occurred'))
console.error(e)
}
},
icon: 'icon-clone',

View File

@@ -135,19 +135,13 @@ export class BoardApi {
})
}
cloneBoard(board) {
return axios.post(this.url(`/boards/${board.id}/clone`))
.then(
(response) => {
return Promise.resolve(response.data)
},
(err) => {
return Promise.reject(err)
}
)
.catch((err) => {
return Promise.reject(err)
})
async cloneBoard(board) {
try {
let response = await axios.post(this.url(`/boards/${board.id}/clone`))
return response.data
} catch (err) {
return err
}
}
// Label API Calls

View File

@@ -280,17 +280,14 @@ export default new Vuex.Store({
commit('addBoard', board)
})
},
cloneBoard({ commit }, boardData) {
return new Promise((resolve, reject) => {
apiClient.cloneBoard(boardData)
.then((board) => {
commit('cloneBoard', board)
resolve(board)
})
.catch((err) => {
return reject(err)
})
})
async cloneBoard({ commit }, boardData) {
try {
let newBoard = await apiClient.cloneBoard(boardData)
commit('cloneBoard', newBoard)
return newBoard
} catch (err) {
return err
}
},
removeBoard({ commit }, board) {
commit('removeBoard', board)