Baidu AI Cloud
中国站

百度智能云

MapReduce

Exception Handling

BMR provides the following ways of exception attention as follows:

Exceptional Method Description
BceHttpClientError Exception occurred in retry
last_error Exception occurred in last retry
BceClientError BMR client exception
BceInvalidArgumentError Exception occurred in passing parameters
BceServerError BMR server exception

You can use “try” to obtain the event exception:

from baidubce.exception import BceHttpClientError
from baidubce.exception import BceServerError

try:
    response = bmr_client.get_step(new_cluster_id, step_id)
    LOG.debug('describe steps response: %s' % response)
except BceHttpClientError as e:
    if isinstance(e.last_error, BceServerError):
        LOG.error('get_step failed. Response %s, code: %s, msg: %s'
                  % (e.last_error.status_code, e.last_error.code, e.last_error.message))
    else:
        LOG.error('get_step failed. Unknown exception: %s' % e)
Previous
BmrClient
Next
Service Level Agreement (SLA)