异常处理
更新时间:2021-10-25
MMS 系统异常提示有如下三种方式:
异常方法 | 说明 |
---|---|
BceHttpClientError | 重试时抛出的异常 |
last_error | 最后一次重试时抛出的异常 |
BceClientError | MMS 客户端产生的异常 |
BceInvalidArgumentError | 传递参数产生的异常 |
BceServerError | MMS 服务器产生的异常 |
用户可以使用try获取某个事件所产生的异常:
try:
mms_client.insert_video(video_lib, source, description=description)
except exception.BceHttpError as e:
print e.message
返回为:
ERROR:__main__:send request failed. Unknown exception: Unable to execute HTTP request. Retried 0 times. All trace backs:
Traceback (most recent call last):
File "/Users/caozibiao/work/code/faiss/anaconda3/lib/python3.8/site-packages/baidubce/http/bce_http_client.py", line 218, in send_request
if handler_function(http_response, response):
File "/Users/caozibiao/work/code/faiss/anaconda3/lib/python3.8/site-packages/baidubce/http/handler.py", line 75, in parse_error
raise bse
baidubce.exception.BceServerError: No unique result find by source=http://bj.bcebos.com/v1/videoai-vio/creative/video/birth_bunny_with_audio-0.mp4
BceServerError: The specified key does not exist.