All Products
Search
Document Center

Object Storage Service:Error handling (C SDK)

Last Updated:Mar 20, 2026

When a request fails, OSS SDK for C returns error details in an aos_status_s struct. Use these details to determine whether to retry the request and to diagnose the root cause.

Error response structure

All failed requests return an aos_status_s struct with the following fields.

FieldTypeDescription
codeIntegerHTTP status code of the failed request
error_codeStringError code returned by OSS
error_msgStringError message returned by OSS
req_idStringUUID that uniquely identifies the request

The following example shows how to inspect these fields after a failed request:

/* Check whether the request succeeded */
if (resp_status->code < 200 || resp_status->code >= 300) {
    /* HTTP status code — use to determine error category */
    printf("HTTP status code: %d\n", resp_status->code);

    /* OSS error code — use to identify the specific error */
    printf("Error code: %s\n", resp_status->error_code);

    /* Human-readable error message */
    printf("Error message: %s\n", resp_status->error_msg);

    /* Request ID — provide this to Alibaba Cloud Support when reporting issues */
    printf("Request ID: %s\n", resp_status->req_id);
}
Note: Save the request ID (req_id) when an error occurs. Alibaba Cloud Support uses this ID to look up the corresponding request logs.

Timeout errors

Timeout errors occur when the connection or request times out. They are indicated by:

  • HTTP status code is not 2xx, and

  • error_code is -992 (connection timeout) or -995 (request timeout)

When a timeout occurs, retry the request. Use aos_should_retry(aos_status_t *) from aos_status.h to determine whether a retry is appropriate:

#include "aos_status.h"

/* aos_should_retry returns 1 if the error warrants a retry */
if (aos_should_retry(resp_status) == 1) {
    /* Retry the request */
}

OSS error codes

OSS error codes are server-side errors returned in error_code. The following tables list common error codes grouped by HTTP status code.

4xx errors

Error codeHTTP status codeDescription
AccessDenied403Access denied
BucketAlreadyExists409The bucket already exists
BucketNotEmpty409The bucket is not empty
EntityTooLarge400The entity size exceeds the maximum limit
EntityTooSmall400The entity size is below the minimum limit
FileGroupTooLarge400The file group size exceeds the maximum limit
FilePartNotExist400The part does not exist
FilePartStale400The part has expired
InvalidArgument400The parameter format is invalid
InvalidAccessKeyId403The AccessKey ID does not exist
InvalidBucketName400The bucket name is invalid
InvalidDigest400The digest is invalid
InvalidObjectName400The object name is invalid
InvalidPart400The part is invalid
InvalidPartOrder400The part sequence is invalid
InvalidTargetBucketForLogging400The logging target bucket is invalid
MalformedXML400The XML format is invalid
MethodNotAllowed405The method is not supported
MissingArgument411One or more required parameters are missing
MissingContentLength411The content length is missing
NoSuchBucket404The bucket does not exist
NoSuchKey404The object does not exist
NoSuchUpload404The multipart upload ID does not exist
PreconditionFailed412An error occurred during preprocessing
RequestTimeTooSkewed403The time difference between the client and OSS server exceeds 15 minutes
RequestTimeout400The request timed out
SignatureDoesNotMatch403The request signature does not match
TooManyBuckets400The number of buckets exceeds the limit

5xx errors

Error codeHTTP status codeDescription
InternalError500An internal OSS error occurred
NotImplemented501The method is not implemented