3333
This commit is contained in:
@@ -18,8 +18,10 @@ import { ElNotification } from "element-plus";
|
||||
* @description 全局代码错误捕捉
|
||||
* */
|
||||
const errorHandler = (error: any) => {
|
||||
// 过滤 HTTP 请求错误
|
||||
if (error.status || error.status == 0) return false;
|
||||
// 过滤 HTTP 请求错误与接口业务返回错误(这类错误已在 Axios 拦截器中统一通过 ElMessage 弹出提示,无需重复告警)
|
||||
if (!error || error.status !== undefined || error.code !== undefined || error.isAxiosError || error.config) {
|
||||
return false;
|
||||
}
|
||||
let errorMap: { [key: string]: string } = {
|
||||
InternalError: "Javascript引擎内部错误",
|
||||
ReferenceError: "未找到对象",
|
||||
@@ -29,10 +31,10 @@ const errorHandler = (error: any) => {
|
||||
EvalError: "错误的使用了Eval",
|
||||
URIError: "URI错误"
|
||||
};
|
||||
let errorName = errorMap[error.name] || "未知错误";
|
||||
let errorName = errorMap[error?.name] || "未知错误";
|
||||
ElNotification({
|
||||
title: errorName,
|
||||
message: error,
|
||||
message: error?.message || String(error),
|
||||
type: "error",
|
||||
duration: 3000
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user