import Vue from "vue";
import { errorLog } from "@/utils/utils";

Vue.config.errorHandler = (error) => {
  errorLog(error.message, {
    stack: error.stack,
    code: "Vue组件错误",
  });
  throw error;
};

window.addEventListener("error", function (event) {
  errorLog(event.message, {
    stack: event?.error?.stack?.replace(/\n/g, "||||"),
    code: "全局JS错误",
  });
});

window.addEventListener("unhandledrejection", function (event) {
  errorLog(event?.reason?.message, {
    stack: event?.error?.stack?.replace(/\n/g, "||||"),
    code: "全局JS错误",
  });
});
