import { ElNotification as s } from "element-plus";
import "axios";
import { errorMessages as l, defaultErrorMessage as n } from "./errorMessages.js";
const p = async (a, i) => {
  console.log("axios-响应中间件(失败响应): 响应失败错误处理中间件已执行");
  const e = a.error, { response: r } = e;
  if (r) {
    const { status: o } = r, t = l[o] || n;
    console.log(`axios-响应中间件(失败响应)原因: HTTP 错误状态码: ${o}`), console.log(`axios-响应中间件(失败响应)原因: 错误信息: ${t}`), s({
      type: "error",
      title: `失败响应错误码：${o}`,
      message: t,
      duration: 6e3
      // 6s自动关闭
    }), o === 401 && console.log("axios-响应中间件(失败响应)原因: 我是401特定状态码执行自定义逻辑");
  } else e.request ? (console.log(
    `axios-响应中间件(失败响应)原因: 网络错误或服务器无响应，请检查网络连接。 ${e.message}`
  ), s({
    type: "error",
    title: "失败响应",
    message: `失败响应原因：网络错误或服务器无响应，请检查网络连接。 ${e.message}`,
    duration: 6e3
    // 6s自动关闭
  })) : (console.log(`axios-响应中间件(失败响应)原因: 请求配置错误: ${e.message}`), s({
    type: "error",
    title: "失败响应",
    message: `失败响应原因：请求配置错误: ${e.message}`,
    duration: 6e3
    // 6s自动关闭
  }));
  await i();
};
export {
  p as handleError
};
