异常
更新时间:2020-10-26
异常提示
BES异常提示有如下两种异常类型:
异常类型 | 说明 |
---|---|
BceHttpClientError | 请求时异常 |
BceServerException | 服务器异常 |
获取事件异常
用户可以使用try获取某个事件所产生的异常,可参考如下代码:
from baidubce.exception import BceHttpClientError
from baidubce.exception import BceServerError
try:
response = bes_client.create_cluster(name,
password,
modules,
version,
slotType,
is_open_service,
available_zone,
security_group_id,
subnet_uuid,
vpc_id,
billing)
print(response)
except BceHttpClientError as e:
if isinstance(e.last_error, BceServerError):
__logger.error('send request failed. Response %s, code: %s, msg: %s'
% (e.last_error.status_code, e.last_error.code, e.last_error.message))
else:
__logger.error('send request failed. Unknown exception: %s' % e)