Files
baserow/web-frontend/modules/builder/utils/error.js
T
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00

33 lines
1.1 KiB
JavaScript

export const handleDispatchError = (err, instance, context = '') => {
const $t = (...params) => {
return !instance.$t ? instance.$i18n.t(...params) : instance.$t(...params)
}
const $store = instance.store || instance.$store
let toastTitle = $t('builderToast.defaultTitle')
let toastMessage = $t('builderToast.defaultMessage')
const errorType = err.response?.data?.error
switch (errorType) {
case 'ERROR_SERVICE_INVALID_DISPATCH_CONTEXT':
toastTitle = $t('builderToast.invalidContextTitle')
toastMessage = $t('builderToast.invalidContextMessage')
break
case 'ERROR_SERVICE_INVALID_DISPATCH_CONTEXT_CONTENT':
toastTitle = $t('builderToast.InvalidContentTitle')
toastMessage = $t('builderToast.invalidContentMessage')
break
case 'ERROR_SERVICE_IMPROPERLY_CONFIGURED':
toastTitle = $t('builderToast.serviceMisconfiguredTitle')
toastMessage = $t('builderToast.serviceMisconfiguredMessage')
break
}
return $store.dispatch('builderToast/error', {
title: toastTitle,
message: `${context}${toastMessage}`,
details: err.response?.data?.detail,
})
}