All Products
Search
Document Center

Object Storage Service:Exception handling (PHP SDK V1)

Last Updated:Mar 20, 2026

The OSS PHP SDK throws an OssException for errors such as invalid parameters and non-existent files. Use the getMessage method to get the error message.

For the full OssException class definition, see OssException.php on GitHub.

Handle an exception

The following example catches an OssException and prints all available diagnostic information — HTTP status code, error code, error message, RequestId, and details.

try {
    $ossClient->createBucket($bucket);
} catch (OssException $e) {
    print("Exception: "          . $e->getMessage()    . "\n");
    print("HTTP status: "        . $e->getHTTPStatus() . "\n");
    print("Error code: "         . $e->getErrorCode()  . "\n");
    print("Error message: "      . $e->getErrorMessage() . "\n");
    print("Request ID: "         . $e->getRequestId()  . "\n");
    print("Details: "            . $e->getDetails()    . "\n");
}

OssException exposes the following properties:

PropertyMethodDescription
HTTPStatusgetHTTPStatus()The HTTP status code.
ErrorCodegetErrorCode()The error code that OSS returns.
ErrorMessagegetErrorMessage()The error message that OSS returns.
RequestIdgetRequestId()A universally unique identifier (UUID) that identifies the request. If you cannot resolve an issue, provide this RequestId to an OSS developer for assistance.
DetailsgetDetails()A detailed description of the error message that OSS returns.

Common OSS error codes

Error codeDescriptionHTTP status code
AccessDeniedAccess 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 file part does not exist.400
FilePartStaleThe file part is stale.400
InvalidArgumentThe parameter format 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 order is invalid.400
InvalidTargetBucketForLoggingThe target bucket for the logging operation is invalid.400
InternalErrorAn internal error occurred in OSS.500
MalformedXMLThe XML format is invalid.400
MethodNotAllowedThe method is not supported.405
MissingArgumentA parameter is missing.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 processed.501
PreconditionFailedA pre-processing error occurred.412
RequestTimeTooSkewedThe difference between the client time and the OSS server time exceeds 15 minutes.403
RequestTimeoutThe request timed out.400
SignatureDoesNotMatchThe signature is incorrect.403
InvalidEncryptionAlgorithmErrorThe specified encryption algorithm is incorrect.400