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