Skip to content
Snippets Groups Projects
Commit 82e0dc7a authored by Janis Streib's avatar Janis Streib :owl:
Browse files

ADD: generic error-handler

parent 0920c7dc
No related branches found
No related tags found
No related merge requests found
......@@ -24,18 +24,28 @@
<Sidebar/>
</b-card>
</div>
<b-modal content-class="text-center" centered id="net-suite-error" hide-footer hide-header size="lg">
<h1><font-awesome-icon icon="poo-storm" size="3x"></font-awesome-icon></h1>
<h3>Etwas ist schief gelaufen...</h3>
<CopyField class="shadow" variant="danger"
:text="global_error"
multiline/>
</b-modal>
</div>
</template>
<script>
import Navbar from './components/Navbar'
import CopyField from './components/CopyField'
import Footer from './components/Footer'
import Sidebar from './components/Sidebar'
import {EventBus} from '@/eventbus'
export default {
components: {Sidebar, Footer, Navbar},
components: {Sidebar, Footer, Navbar, CopyField},
data() {
return {
global_error: null,
breadcrumbs: []
}
},
......@@ -71,6 +81,13 @@ export default {
},
mounted() {
window.console.log('%c ', `font-size:0px; padding: 200px; background:url(${window.location.protocol}//${window.location.hostname}:${window.location.port}/important.webp) no-repeat; background-position: center; background-size: contain;`)
const self = this
EventBus.$on('error', (payload) => {
window.console.debug('evbus trigger')
window.console.debug(payload)
self.global_error = JSON.stringify(payload, null, 4)
this.$bvModal.show('net-suite-error')
})
}
}
</script>
......
import Vue from 'vue'
export default {}
export const EventBus = new Vue()
......@@ -47,7 +47,8 @@ import {
faMapSigns,
faNetworkWired,
faHistory,
faEthernet
faEthernet,
faPooStorm
} from '@fortawesome/free-solid-svg-icons'
import {
......@@ -115,5 +116,6 @@ library.add(
faMapSigns,
faNetworkWired,
faHistory,
faEthernet
faEthernet,
faPooStorm
)
......@@ -16,6 +16,7 @@ import vuexUndoRedo from './mixins/vuex-undo-redo'
import APIUtil from './util/apiutil'
import WAPITransactionSerice from './api-services/transaction.service'
import LoginService from '@/api-services/login.service'
import {EventBus} from '@/eventbus'
Vue.use(Vuex)
Vue.mixin(titleMixin)
......@@ -46,6 +47,22 @@ async function init() {
this.splice(to, 0, this.splice(from, 1)[0])
return this
}
if (!('toJSON' in Error.prototype)) {
// eslint-disable-next-line no-extend-native
Object.defineProperty(Error.prototype, 'toJSON', {
value: function () {
var alt = {}
Object.getOwnPropertyNames(this).forEach(function (key) {
alt[key] = this[key]
}, this)
return alt
},
configurable: true,
writable: true
})
}
const store = new Vuex.Store({
state: {
......@@ -279,11 +296,15 @@ async function init() {
// `info` is a Vue-specific error info, e.g. which lifecycle hook
// the error was found in. Only available in 2.2.0+
// alert(err, info)
window.console.debug('vue-error handler triggered')
window.console.log(err, info)
EventBus.$emit('error', err)
}
window.onerror = function (message, source, lineno, colno, error) {
window.console.debug('window-error handler triggered')
window.console.log(error)
EventBus.$emit('error', error)
}
Axios.interceptors.response.use(
function (response) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment