This topic describes how to handle errors when you use OSS SDK for C.

Exception handling

If an error occurs when you send a request by using OSS SDK for C, the corresponding error message is returned in aos_status_s. The following table describes the attributes of aos_status_s.

Error codeDescriptionType
codeThe HTTP status code of the error request. Integer
error_codeThe error code returned by OSS. String
error_msgThe error message returned by OSS. String
req_idThe UUID that identifies the request. You can provide req_id to OSS development engineers for help. String

Timeout handling

If the HTTP status code in the returned aos_status_t parameter is not 2xx and error_code indicates -992 or -995, the connection or request times out. You can send the request again.

You can use aos_should_retry(aos_status_t *) in the aos_status.h file to determine whether an error requires a retry based on the returned value. If a value of 1 is returned, you need to perform a retry for the error.

Common error codes

Error codeError messageHTTP status code
AccessDeniedAccess is denied.403
BucketAlreadyExistsThe bucket already exists.409
BucketNotEmptyThe bucket is not empty.409
EntityTooLargeThe entity is too large.400
EntityTooSmallThe entity is too small.400
FileGroupTooLargeThe file group is too large.400
FilePartNotExistThe part does not exist.400
FilePartStaleThe part has expired.400
InvalidArgumentThe format of the parameter is invalid.400
InvalidAccessKeyIdThe AccessKey ID does not exist.403
InvalidBucketNameThe bucket name is invalid.400
InvalidDigestThe digest is invalid.400
InvalidObjectNameThe object name is invalid.400
InvalidPartThe part is invalid.400
InvalidPartOrderThe part sequence is invalid.400
InvalidTargetBucketForLoggingThe bucket for logging is invalid.400
InternalErrorAn internal OSS error occurred.500
MalformedXMLThe XML format is invalid.400
MethodNotAllowedThe method is not supported.405
MissingArgumentSome required parameters are not specified.411
MissingContentLengthThe content length is missing.411
NoSuchBucketThe bucket does not exist.404
NoSuchKeyThe object does not exist.404
NoSuchUploadThe multipart upload ID does not exist.404
NotImplementedThe method cannot be implemented.501
PreconditionFailedAn error occurred during preprocessing.412
RequestTimeTooSkewedThe time deviation of the OSS client and OSS server exceeds 15 minutes.403
RequestTimeoutThe request timed out.400
SignatureDoesNotMatchA signature error occurred.403
TooManyBucketsThe number of buckets exceeds the limit.400