Skip to content

Commit

Permalink
Navigate to new view only if request creation succeeded + better erro…
Browse files Browse the repository at this point in the history
…r display
  • Loading branch information
benoit74 committed Sep 20, 2024
1 parent 52e1d91 commit 408e4a5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ui/src/stores/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ export const useMainStore = defineStore('main', {
await axios.post<PostRequestResponse>(this.config.zimit_ui_api + '/requests', payload)
).data
this.taskId = response.id
this.router.push({ name: 'request', params: { taskId: this.taskId } })
} catch (error) {
this.handleError(this.t('newRequest.errorCreatingRequest'), error)
} finally {
this.setLoading({ loading: false })
}
this.router.push({ name: 'request', params: { taskId: this.taskId } })
},
handleError(message: string, error: unknown) {
if (error instanceof AxiosError) {
console.error(message, ':', error.response?.status, error.response?.statusText)
if (error instanceof AxiosError && error.response) {
console.error(message, ':', error.response.status, error.response.statusText)
} else {
console.error(message, ':', error)
}
Expand Down

0 comments on commit 408e4a5

Please sign in to comment.