feat: don't rethrow same error and handle errors globally
This commit is contained in:
parent
6f51921588
commit
3b940cb56c
71 changed files with 69 additions and 451 deletions
22
src/main.ts
22
src/main.ts
|
|
@ -96,10 +96,30 @@ app.config.errorHandler = (err, vm, info) => {
|
|||
// if (import.meta.env.PROD) {
|
||||
// error(err)
|
||||
// } else {
|
||||
console.error(err, vm, info)
|
||||
// console.error(err, vm, info)
|
||||
error(err)
|
||||
// }
|
||||
}
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
app.config.warnHandler = (msg, vm, info) => {
|
||||
error(msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// https://stackoverflow.com/a/52076738/15522256
|
||||
window.addEventListener('error', (err) => {
|
||||
error(err)
|
||||
})
|
||||
|
||||
|
||||
window.addEventListener('unhandledrejection', (err) => {
|
||||
// event.promise contains the promise object
|
||||
// event.reason contains the reason for the rejection
|
||||
error(err)
|
||||
})
|
||||
|
||||
app.config.globalProperties.$message = {
|
||||
error,
|
||||
success,
|
||||
|
|
|
|||
Reference in a new issue