百度智能云

All Product Document

          Object Storage

          Exception Handling

          System Exception

          BOS system exception is prompted in the following 3 ways

          Exception method Description
          BceHttpClientError Exception thrown during retry
          last_error Exception thrown during the final retry
          BceClientError Exception generated by BOS client
          BceInvalidArgumentError Exception generated by introduced parameter
          BceServerError Exception generated by BOS server

          You can use try to get exceptions generated by an event:

          from baidubce import exception
          from baidubce.services import bos
          
          try:
              bos_client.delete_object(bucket_name, object_key)
          except exception.BceHttpError as e:
              print e.message

          Returned as:

          BceHttpClientError: Unable to execute HTTP request. Retried 0 times. All trace backs:
          Traceback (most recent call last):
          File "/home/work/python-2.7/lib/python2.7/site-packages/baidubce/http/bce_http_client.py", line 184, in send_request
          if handler_function(http_response, response):
          File "/home/work/python-2.7/lib/python2.7/site-packages/baidubce/http/handler.py", line 71, in parse_error raise bse
          BceServerError: The specified key does not exist.

          Client Exception

          Client exception indicates an exception encountered when the client attempts to send a request to the BOS and transmits data. For example, when the network connection is unavailable during request sending, BceHttpClientError is thrown; in case of IO exception during file upload, BceClientError is also thrown.

          Server Exception

          When an exception occurs on the BOS server, the BOS server returns the corresponding error message to the user to locate the problem. Common server exceptions can be found in BOS Error Message Format.

          Parameter Exception

          Each call of BOS Python SDK has some parameters that cannot be null with type fixed, and if such parameter returns a null value, ValueError is returned, and if such parameter introduces type error, TypeError is returned.

          The relationship between parameters and calling is as follows:

          BOS callingparameterdescription type
          create_bucket, does_bucket_exist, delete_bucket, get_bucket_location, get_bucket_lifecycle, delete_bucket_lifecycle, get_bucket_cors, delete_bucket_cors, get_bucket_logging, delete_bucket_logging, list_objects, list_all_objects, delete_object, get_bucket_acl, list_multipart_uploads, list_all_multipart_uploadsbucket_namebucket namestring, unicode
          put_bucket_loggingsource_bucket-target_bucketName of source bucket and target bucketstring, unicode
          set_bucket_aclbucket_namebucket namestring, unicode
          aclACL body contains authorized person and permissionlist, dict
          set_bucket_canned_aclbucket_namebucket namestring, unicode
          canned_aclCannedAcl permissionstring
          put_bucket_lifecyclebucket_namebucket namestring, unicode
          rulesLifecycle management rule body, containing resources and operation actionlist, dict
          put_bucket_corsbucket_namebucket namestring, unicode
          cors_configurationCross-origin resource sharing (CORS) rule body, containing source of permitted cross-origin request, permitted header, etc.list, dict
          get_object, get_object_as_string, get_object_meta_data, initiate_multipart_upload, generate_pre_signed_urlbucket_namebucket namestring, unicode
          keyobject namestring
          get_object_to_file, put_object_from_filebucket_namebucket namestring, unicode
          keyobject namestring
          file_nameFile namestring
          put_object, append_objectbucket_namebucket namestring, unicode
          keyobject namestring
          dataStream objectobject
          content_lengthUpload size of objectint, long
          content_md5Upload MD5 of objectstring
          put_object_from_string-append_object_from_stringbucket_namebucket namestring, unicode
          keyobject namestring
          dataUpload stringstring, unicode
          copy_objectsource_bucket_name, target_bucket_nameName of source bucket and target bucketstring, unicode
          source_key, target_keyName of source object and target objectstring
          upload_partbucket_name, upload_idbucket name, identify MultUpload operation global IDstring, unicode
          keyobject namestring
          part_numberPart numberint
          part_sizeUpload part sizeint, long
          part_fpUpload part objectobject
          upload_part_from_filebucket_name, upload_idbucket name, identify MultUpload operation global IDstring, unicode
          keyobject namestring
          part_numberPart numberint
          part_sizeUpload part sizeint, long
          file_nameFile namestring
          offsetoffset starting position of partint
          complete_multipart_uploadbucket_name, upload_idbucket name, identify MultUpload operation global IDstring, unicode
          keyobject namestring
          part_listPart listlist
          abort_multipart_upload, list_parts, list_all_partsbucket_name, upload_idbucket name, identify MultUpload operation global IDstring, unicode
          keyobject namestring
          delete_multiple_objectsbucket_namebucket namestring, unicode
          key_listobject listlist
          Previous
          Log Control
          Next
          Version Change Record