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

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

* fix: add axios error info from response
This commit is contained in:
CXM 2021-08-16 23:14:40 +08:00 committed by GitHub
parent c420174c1d
commit 72634ffe6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios';
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
import type { RequestOptions, Result, UploadFileParams } from '../../../../types/axios';
import type { CreateAxiosOptions } from './axiosTransform';
import axios from 'axios';
@ -220,11 +220,14 @@ export class VAxios {
}
resolve(res as unknown as Promise<T>);
})
.catch((e: Error) => {
.catch((e: Error | AxiosError) => {
if (requestCatchHook && isFunction(requestCatchHook)) {
reject(requestCatchHook(e, opt));
return;
}
if (axios.isAxiosError(e)) {
// rewrite error message from axios in here
}
reject(e);
});
});