1
0

fix: namespace collision of global error method with draggable error method

This commit is contained in:
Dominik Pschenitschni
2021-08-25 12:28:29 +02:00
committed by kolaente
parent 0da7a46612
commit ebeca48be4
57 changed files with 229 additions and 209 deletions

View File

@ -1,9 +1,11 @@
export const getErrorText = (r, $t) => {
import {i18n} from '@/i18n/setup'
export const getErrorText = (r) => {
if (r.response && r.response.data) {
if(r.response.data.code) {
const path = `error.${r.response.data.code}`
const message = $t(path)
const message = i18n.t(path)
// If message and path are equal no translation exists for that error code
if (path !== message) {
@ -25,23 +27,23 @@ export const getErrorText = (r, $t) => {
return [r.message]
}
export default {
error(e, context, $t, actions = []) {
context.$notify({
type: 'error',
title: $t('error.error'),
text: getErrorText(e, $t),
export function error(e, context, actions = []) {
context.$notify({
type: 'error',
title: i18n.t('error.error'),
text: getErrorText(e),
actions: actions,
})
console.error(e, actions)
}
export function success(e, context, actions = []) {
context.$notify({
type: 'success',
title: i18n.t('error.success'),
text: getErrorText(e),
data: {
actions: actions,
})
},
success(e, context, $t, actions = []) {
context.$notify({
type: 'success',
title: $t('error.success'),
text: getErrorText(e, $t),
data: {
actions: actions,
},
})
},
},
})
}