"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createErrorHandler = createErrorHandler;
// 第三方依赖
const isFunction_1 = __importDefault(require("lodash/isFunction"));
/**
 * 创建错误处理函数
 */
function createErrorHandler(options) {
    const { remote, innerInfo, setLoading, releaseLock } = options;
    return function errorHandler(...args) {
        setLoading(false);
        releaseLock();
        if ((0, isFunction_1.default)(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);
        }
    };
}
