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 import type { RequestOptions, Result, UploadFileParams } from '../../../../types/axios'; 2 import type { RequestOptions, Result, UploadFileParams } from '../../../../types/axios';
3 import type { CreateAxiosOptions } from './axiosTransform'; 3 import type { CreateAxiosOptions } from './axiosTransform';
4 import axios from 'axios'; 4 import axios from 'axios';
@@ -220,11 +220,14 @@ export class VAxios { @@ -220,11 +220,14 @@ export class VAxios {
220 } 220 }
221 resolve(res as unknown as Promise<T>); 221 resolve(res as unknown as Promise<T>);
222 }) 222 })
223 - .catch((e: Error) => { 223 + .catch((e: Error | AxiosError) => {
224 if (requestCatchHook && isFunction(requestCatchHook)) { 224 if (requestCatchHook && isFunction(requestCatchHook)) {
225 reject(requestCatchHook(e, opt)); 225 reject(requestCatchHook(e, opt));
226 return; 226 return;
227 } 227 }
  228 + if (axios.isAxiosError(e)) {
  229 + // rewrite error message from axios in here
  230 + }
228 reject(e); 231 reject(e);
229 }); 232 });
230 }); 233 });