Skip to content
Snippets Groups Projects
Commit d810ab84 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

add API error handling facility

parent c53b4541
No related branches found
No related tags found
No related merge requests found
export default function handleApiError (vm, err, message) {
if (err.response) {
vm.$log.error(err.response.status + ' ' + err.response.statusText)
vm.$log.error(err.response)
let msg = 'Error: '
if (message) {
msg += message
}
msg += '\n\n'
msg += 'Status code: ' + err.response.status + ' ' + err.response.statusText
alert(msg)
} else {
vm.$log.error(err)
if (message) {
alert('Error: ' + message + '\nInspect the console for more details.')
} else {
alert('Unspecified error. Inspect the console for details.')
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment