api.py 文件源码

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

项目:bonsai-cli 作者: BonsaiAI 项目源码 文件源码
def _handles_connection_error(func):
    """
    Decorator for handling ConnectionErrors raised by the requests
    library, raises a BrainServerError instead.

    :param func: the function being decorated
    """
    @functools.wraps(func)
    def _handler(self, url, *args, **kwargs):
        try:
            return func(self, url, *args, **kwargs)
        except requests.exceptions.ConnectionError as e:
            message = "Unable to connect to domain: {}".format(url)
            raise BrainServerError(message)

    return _handler
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号