Commit 72634ffe6e6649d36ee41f7633c8ee2ab80cf25e

Authored by CXM
Committed by GitHub
1 parent c420174c

fix: add axios error info from response (#1083)

* fix(type): fix ant-design-vue  ->

* fix: add axios error info from response
Showing 1 changed file with 5 additions and 2 deletions
src/utils/http/axios/Axios.ts
1   -import type { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios';
  1 +import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
2 2 import type { RequestOptions, Result, UploadFileParams } from '../../../../types/axios';
3 3 import type { CreateAxiosOptions } from './axiosTransform';
4 4 import axios from 'axios';
... ... @@ -220,11 +220,14 @@ export class VAxios {
220 220 }
221 221 resolve(res as unknown as Promise<T>);
222 222 })
223   - .catch((e: Error) => {
  223 + .catch((e: Error | AxiosError) => {
224 224 if (requestCatchHook && isFunction(requestCatchHook)) {
225 225 reject(requestCatchHook(e, opt));
226 226 return;
227 227 }
  228 + if (axios.isAxiosError(e)) {
  229 + // rewrite error message from axios in here
  230 + }
228 231 reject(e);
229 232 });
230 233 });
... ...