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?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e59a6d-45557.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e59a6d-45557.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?