How does vue catch errors on the page and submit them to the background through api

now the requirement is to catch the error on the page and submit it to the background. Now I can only catch the network error through the interceptor. Excuse me, how to catch the error and where to write it?

Apr.03,2021

rewrite Vue.config.errorHandler = function (err, vm) {
= > send a http request to the backend
}


// window error
window.onerror = (msg, url, line, col, error) => {
    var _msg = handleErrorMsg(error)
    console.log(error)
    report({
        type: 'window ERROR',
        msg: _msg,
        level: 'fatal'
    })
    return true // errorerror
}

// promise rejecttion promise
window.addEventListener('unhandledrejection', e => {
    report({
        type: 'unhandledrejection',
        level: 'fatal',
        msg: e.reason
    })
    return true
})

// vuewindow.error
Vue.config.errorHandler = function (error, vm, msg) {
    var _msg = handleErrorMsg(error)
    console.log(error)
    report({
        type: 'Vue errorHandler',
        level: 'fatal',
        error,
        msg: _msg
    })
}

what are the types of errors you're talking about?


look at this https://codeshelper.com/a/11.


has the landlord solved the capture problem?
and @ frontoldman landlord, what is the operation of the handleErrorMsg method written in you?

Menu