redirect to logs when error has 'log_ref'

This commit is contained in:
Axolotle 2020-11-26 17:17:51 +01:00
parent 865491831d
commit d26fa43e5f
2 changed files with 7 additions and 4 deletions

View file

@ -5,6 +5,7 @@
import store from '@/store'
import errors from './errors'
import router from '@/router'
/**
* Try to get response content as json and if it's not as text.
@ -47,12 +48,14 @@ export function handleResponse (response, method) {
export async function handleError (response, method) {
const message = await _getResponseContent(response)
const errorCode = response.status in errors ? response.status : undefined
const error = new errors[errorCode](method, response, message)
const error = new errors[errorCode](method, response, message.error || message)
if (error.code === 401) {
store.dispatch('DISCONNECT')
} else if (error.code === 400) {
// FIXME for now while in form, the error is catched by the caller and displayed in the form
if (typeof message !== 'string' && 'log_ref' in message) {
router.push({ name: 'tool-log', params: { name: message.log_ref } })
}
// Hide the waiting screen
store.dispatch('SERVER_RESPONDED', true)
} else {

View file

@ -1,5 +1,5 @@
<template>
<div class="error mt-4" v-if="error">
<div class="error mt-4 mb-5" v-if="error">
<h2>{{ $t('api_errors_titles.' + error.name) }} :/</h2>
<em v-t="'api_error.sorry'" />
@ -16,7 +16,7 @@
<pre><code>"{{ error.method }}" {{ error.uri }}</code></pre>
<h5>Message</h5>
<p>{{ error.message }}</p>
<p v-html="error.message" />
<template v-if="error.traceback">
<h5 v-t="'traceback'" />