export function httpErrorHandler(err, req, res, next) {
    console.log("in httpErrorHandler");
    console.log(err);
    if (err) {
        if (err.message == "Excel文件不存在") {
            res.success({success: false, msg: err.message, code: 501});
            next();
        }
        else if (err.message == "表格不存在") {
            res.success({success: false, msg: err.message, code: 502});
            next();
        }
        else if (err.message == "Date parameter is required.") {
            res.success({success: false, msg: err.message, code: 503});
            next();
        }
        else if (err.message == "Date and sight parameters are required.") {
            res.success({success: false, msg: err.message, code: 504});
            next();
        }
        else if (err.message == "Invalid strategy type.") {
            res.success({success: false, msg: "不支持该请求", code: 505});
            next();
        }
        else if (err.message == 'Year parameter is required.') {
            res.success({success: false, msg: err.message, code: 506});
            next();
        }
        else if (err.message == 'Year parameter must be either "thisyear" or "lastyear".') {
            res.success({success: false, msg: err.message, code: 507});
            next();
        }
        else if (err.message == 'timeFrame parameter is required.') {
            res.success({success: false, msg: err.message, code: 508});
            next();
        }
        else if (err.message == 'metric parameter is required.') {
            res.success({success: false, msg: err.message, code: 509});
            next();
        }
        else if (err.message == 'category parameter is required.') {
            res.success({success: false, msg: err.message, code: 510});
            next();
        }
        else if (err.message == 'sight parameter must be one of 安丰塘（芍跛）, 清真寺, 孔庙, 汐熙阁, 安徽第一面党旗纪念园, 八公山森林公园, 寿州古城游客中心, 珍珠泉, 随缘堂（周易）.') {
            res.success({success: false, msg: err.message, code: 511});
            next();
        }
        else if (err.message == 'sight parameter is required.') {
            res.success({success: false, msg: err.message, code: 512});
            next();
        }
        else if (err.message == 'metric parameter must be one of ticket, ecommerce.') {
            res.success({success: false, msg: err.message, code: 515});
            next();
        }
        else {
            res.success({success:false, msg: err.message, code: 500});
            next();
        }
    }
}