All Products
Search
Document Center

Object Storage Service:Error handling

Last Updated:Sep 19, 2023

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 errors returned in aos_status_s.

Error code

Description

Type

code

The HTTP status code of the error request.

Integer

error_code

The error code returned by OSS.

String

error_msg

The error message returned by OSS.

String

req_id

The UUID that identifies the request.

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 code

Error message

HTTP status code

AccessDenied

Access is denied.

403

BucketAlreadyExists

The bucket already exists.

409

BucketNotEmpty

The bucket is not empty.

409

EntityTooLarge

The entity size exceeds the maximum limit.

400

EntityTooSmall

The entity size is below the minimum limit.

400

FileGroupTooLarge

The file group size exceeds the maximum limit.

400

FilePartNotExist

The part does not exist.

400

FilePartStale

The part has expired.

400

InvalidArgument

The format of the parameter is invalid.

400

InvalidAccessKeyId

The AccessKey ID does not exist.

403

InvalidBucketName

The bucket name is invalid.

400

InvalidDigest

The digest is invalid.

400

InvalidObjectName

The object name is invalid.

400

InvalidPart

The part is invalid.

400

InvalidPartOrder

The part sequence is invalid.

400

InvalidTargetBucketForLogging

The bucket for logging is invalid.

400

InternalError

An internal OSS error occurred.

500

MalformedXML

The XML format is invalid.

400

MethodNotAllowed

The method is not supported.

405

MissingArgument

Some required parameters are not specified.

411

MissingContentLength

The content length is missing.

411

NoSuchBucket

The bucket does not exist.

404

NoSuchKey

The object does not exist.

404

NoSuchUpload

The multipart upload ID does not exist.

404

NotImplemented

The method cannot be implemented.

501

PreconditionFailed

An error occurred during preprocessing.

412

RequestTimeTooSkewed

The time deviation of the OSS client and OSS server exceeds 15 minutes.

403

RequestTimeout

The request timed out.

400

SignatureDoesNotMatch

A signature error occurred.

403

TooManyBuckets

The number of buckets exceeds the limit.

400