问题描述
我有一个使用异常处理的小 Python 代码。
def handler(event):
try:
client = boto3.client('dynamodb')
response = client.scan(TableName=os.environ["datapipeline_table"])
return response
except Exception as error:
logging.exception("GetPipelinesError: %s",json.dumps(error))
raise GetPipelinesError(json.dumps({"httpStatus": 400,"message": "Unable to fetch Pipelines"}))
class GetPipelinesError(Exception):
pass
pylint 警告给了我“考虑使用 'from' 关键字明确重新加注”。 我很少看到其他帖子,他们使用 from 并引发错误。我做了这样的修改
except Exception as GetPipelinesError:
logging.exception("GetPipelinesError: %s",json.dumps(GetPipelinesError))
raise json.dumps({"httpStatus": 400,"message": "Unable to fetch Pipelines"}) from GetPipelinesError
这是正确的做法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)