Skip to content

Commit

Permalink
Log exceptions in console
Browse files Browse the repository at this point in the history
  • Loading branch information
ifox committed Jul 5, 2020
1 parent 56b5bc2 commit c6956b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions frontend/js/store/modules/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,13 @@ const actions = {
}
}, function (errorResponse) {
commit(FORM.UPDATE_FORM_LOADING, false)
commit(FORM.SET_FORM_ERRORS, errorResponse.response.data)
commit(NOTIFICATION.SET_NOTIF, { message: 'Your submission could not be validated, please fix and retry', variant: 'error' })

if (errorResponse.response.data.hasOwnProperty('exception')) {
commit(NOTIFICATION.SET_NOTIF, { message: 'Your submission could not be processed.', variant: 'error' })
} else {
commit(FORM.SET_FORM_ERRORS, errorResponse.response.data)
commit(NOTIFICATION.SET_NOTIF, { message: 'Your submission could not be validated, please fix and retry', variant: 'error' })
}
})
}
}
Expand Down
8 changes: 5 additions & 3 deletions frontend/js/utils/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ export function globalError (component = null, error = { message: '', value: nul
prefix = `${process.env.VUE_APP_NAME} - [${component}]: `
}

const errorMessage = prefix + 'An error occured.\n' + error.message
const errorMessage = prefix + error.message

console.error(errorMessage)
if (error.value) {
console.error(error.value)

if (error.value && error.value.response) {
console.error(error.value.response.data)
}

if ('response' in error.value && 'status' in error.value.response && error.value.response.status === 401) {
Expand Down

0 comments on commit c6956b8

Please sign in to comment.