我有一个layui编写的页面,当后端正常返回时显示正常问题,但是后端返回失败信息(但是返回码还是200)时就显示异常。涉及代码如下:

    def vhosthis_sync():
        querydata = g.session.query(VhostInfo, BusinessInfo).join(BusinessInfo, VhostInfo.bus_id == BusinessInfo.ename).filter(VhostInfo.status == VhostInfoStatus.ARCHIVE)
        host_type = g.session.query(ParamDefined).filter(ParamDefined.dtype == 'modules').all()
        hosttypedict = {}
        for host_type_item in host_type:
            hosttypedict[host_type_item.dkey] = host_type_item.dvalue
        acount = querydata.count()
        results = querydata.all()
        try:
            for vhostinfo, businessinfo in results:
                vhostinfohis = VhostInfoHis()
                if vhostinfo.host_type in hosttypedict.keys():
                    vhostinfohis.dvalue = hosttypedict[vhostinfo.host_type]
                else:
                    vhostinfohis.dvalue = '待分类'
                for key,value in vars(vhostinfo).items():
                    if hasattr(vhostinfohis,key):
                        setattr(vhostinfohis,key,value)
                for key,value in vars(businessinfo).items():
                    if hasattr(vhostinfohis,key):
                        setattr(vhostinfohis,key,value)
                print(vars(vhostinfohis))
                g.session.add(vhostinfohis)
                g.session.commit()
            return jsonify({'code': 200,'msg':'同步成功,本次同步数据量:'+str(acount)})
        except Exception as e:
            print(e)
            return jsonify({'code':400,'msg':str(e.args)})