mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
redirect to logs when error has 'log_ref'
This commit is contained in:
parent
865491831d
commit
d26fa43e5f
2 changed files with 7 additions and 4 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import errors from './errors'
|
import errors from './errors'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to get response content as json and if it's not as text.
|
* 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) {
|
export async function handleError (response, method) {
|
||||||
const message = await _getResponseContent(response)
|
const message = await _getResponseContent(response)
|
||||||
const errorCode = response.status in errors ? response.status : undefined
|
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) {
|
if (error.code === 401) {
|
||||||
store.dispatch('DISCONNECT')
|
store.dispatch('DISCONNECT')
|
||||||
} else if (error.code === 400) {
|
} 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
|
// Hide the waiting screen
|
||||||
store.dispatch('SERVER_RESPONDED', true)
|
store.dispatch('SERVER_RESPONDED', true)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<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>
|
<h2>{{ $t('api_errors_titles.' + error.name) }} :/</h2>
|
||||||
|
|
||||||
<em v-t="'api_error.sorry'" />
|
<em v-t="'api_error.sorry'" />
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<pre><code>"{{ error.method }}" {{ error.uri }}</code></pre>
|
<pre><code>"{{ error.method }}" {{ error.uri }}</code></pre>
|
||||||
|
|
||||||
<h5>Message</h5>
|
<h5>Message</h5>
|
||||||
<p>{{ error.message }}</p>
|
<p v-html="error.message" />
|
||||||
|
|
||||||
<template v-if="error.traceback">
|
<template v-if="error.traceback">
|
||||||
<h5 v-t="'traceback'" />
|
<h5 v-t="'traceback'" />
|
||||||
|
|
Loading…
Reference in a new issue