fix: 处理 default 异常问题?

This commit is contained in:
winixt 2022-04-29 15:51:42 +08:00
parent bae7c46200
commit 65ff06cf4a
2 changed files with 6 additions and 3 deletions

View File

@ -168,8 +168,11 @@ function handleRequestError({
const errorKey = getErrorKey(error, response);
if (!isSkipErrorHandler(config, errorKey)) {
const errorHandlerFn = errorHandler[errorKey || 'default'];
errorHandlerFn && errorHandlerFn(error, response);
if (isFunction(errorHandler[errorKey])) {
errorHandler[errorKey](error, response);
} else if (isFunction(errorHandler.default)) {
errorHandler.default(error, response);
}
}
}

View File

@ -41,7 +41,7 @@ export default {
const get = () => {
request('/api', null, {
skipErrorHandler: '123'
skipErrorHandler: ['500']
}).catch((err) => {
console.log('skip error', err);
});