异常处理
更新时间:2021-02-08
MCA 系统异常提示有如下三种方式:
异常方法 | 说明 |
---|---|
BceHttpClientError | 重试时抛出的异常 |
last_error | 最后一次重试时抛出的异常 |
BceClientError | MCA 客户端产生的异常 |
BceInvalidArgumentError | 传递参数产生的异常 |
BceServerError | MCA 服务器产生的异常 |
用户可以使用try获取某个事件所产生的异常:
try:
vca_client.put_media(source, preset, notification)
except exception.BceHttpError as e:
print e.message
返回为:
BceHttpClientError: Unable to execute HTTP request. Retried 0 times. All trace backs:
Traceback (most recent call last):
File “/home/work/python-2.7/lib/python2.7/site-packages/baidubce/http/bce_http_client.py”, line 184, in send_request
if handler_function(http_response, response):
File “/home/work/python-2.7/lib/python2.7/site-packages/baidubce/http/handler.py”, line 71, in parse_error raise bse
BceServerError: The specified key does not exist.