// 第三方依赖
import isFunction from 'lodash/isFunction';
/**
 * 创建错误处理函数
 */
export function createErrorHandler(options) {
    const { remote, innerInfo, setLoading, releaseLock } = options;
    return function errorHandler(...args) {
        setLoading(false);
        releaseLock();
        if (isFunction(remote === null || remote === void 0 ? void 0 : remote.failCallback)) {
            remote === null || remote === void 0 ? void 0 : remote.failCallback(...args);
        }
        if (innerInfo && typeof innerInfo.setDataSource === 'function') {
            innerInfo.setDataSource([]);
        }
        if ((innerInfo === null || innerInfo === void 0 ? void 0 : innerInfo.pageInfo) && typeof innerInfo.pageInfo.setTotal === 'function') {
            innerInfo.pageInfo.setTotal(0);
        }
    };
}
