所有文档

          音视频处理 MCT

          异常处理

          系统异常

          Media异常提示有如下三种方式:

          异常方法 说明
          BceHttpClientError 重试时抛出的异常
          --last_error 最后一次重试时抛出的异常
          ----BceClientError Media客户端产生的异常
          ----BceInvalidArgumentError 传递参数产生的异常
          ----BceServerError Media服务器产生的异常

          用户可以使用try获取某个事件所产生的异常:

          from baidubce.exception import BceHttpClientError
          from baidubce.exception import BceServerError
          from baidubce.exception import BceClientError
          try:
              watermark_id = "non_exist"
              client.delete_watermark(watermark_id)
          except BceHttpClientError as e:
              print "Cannot delete the watermark: ", e.message

          返回为:

          Cannot delete the watermark:  Unable to execute HTTP request. Retried 0 times. A
          ll trace backs:
          >>>>Traceback (most recent call last):
          >>>>  File "C:\tools\Python27\lib\site-packages\baidubce\http\bce_http_client.py
          ", line 183, in send_request
          >>>>    if handler_function(http_response, response):
          >>>>  File "C:\tools\Python27\lib\site-packages\baidubce\http\handler.py", line
          71, in parse_error
          >>>>    raise bse
          >>>>BceServerError: watermark: non_exist does not exist
          
          也可以用这种方式直接获取原始错误信息:
          print "Cannot delete the watermark: ", e.last_error.message
          得到:
          Cannot delete the watermark: watermark: non_exist does not exist

          参数异常

          Media Python SDK的每个调用都有一些类型固定不可以为空的参数,若该参数传入为空值则返回BceClientError,若该参数传入类型错误则返回TypeError。

          上一篇
          Notification(通知)
          下一篇
          版本变更记录