__init__.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Isa-Framework 作者: c0hb1rd 项目源码 文件源码
def capture(f):
    def decorator(*args, **options):
        # ??????
        try:
            # ??????
            rep = f(*args, **options)
        except SYLFkException as e:
            # ???? SYLFkException ??????????????????????????? ERROR_MAP ????????????????
            if e.code in ERROR_MAP and ERROR_MAP[e.code]:

                # ?????????
                rep = ERROR_MAP[e.code]

                # ???????? 100??????????? 500 ?????
                status = int(e.code) if int(e.code) >= 100 else 500

                # ????????????????????????????????????????????
                return rep if isinstance(rep, Response) or rep is None else Response(rep(), content_type=content_type, status=status)
            else:
                # ?????????????
                raise e
        # ???????????
        return rep
    # ?????
    return decorator
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号