dict
or None
. If an SDK API call to request the COS service fails, the system will throw CosClientError
(client exception) or CosServiceError
(server exception).CosClientError
, results from unexpected interaction issues between the client and the COS server, such as a failure to connect to the server, a failure to parse the data returned by the server, or the occurrence of an IO exception when reading a local file. CosServiceError
, occurs when the client interacts with the COS server normally, but the operation fails. For example, the client accesses a bucket that does not exist, deletes an object that does not exist, or does not have the permission to perform an operation.CosClientError
generally refers to a client error caused by issues such as timeout. When capturing such an error, you can choose to retry or perform other operations.CosServiceError
contains the detailed information returned by the server, including the status code, request ID, and error details. After such an exception is captured, it is recommended that you print out the entire exception as it contains necessary factors for troubleshooting. The following describes the member variables of the exception and provides an example of exception capturing.Member | Description | Type |
request_id | Request ID, used to identify a request. It is very important for troubleshooting. | string |
status_code | string | |
error_code | string | |
error_msg | string |
from qcloud_cos import CosServiceErrorexcept CosServiceError as e:e.get_origin_msg() # Get the original error message in XML formate.get_digest_msg() # Get the processed error message in dict formate.get_status_code() # Get the HTTP error code (e.g. 4xx, 5xx)e.get_error_code() # Get the COS-defined error codee.get_error_msg() # Get a detailed description of the COS error codee.get_trace_id() # Get the trace_id of the requeste.get_request_id() # Get the request_id of the requeste.get_resource_location() # Get the URL
RequestId
) returned when the request error occurs.RequestId
and click Diagnose.
Was this page helpful?