OSS SDK for PHP exceptions (OssException) include errors caused by invalid parameters and objects that do not exist. You can call getMessage to obtain an error message.

For more information about OssException, visit GitHub.

Example of handling exceptions

The following code provides an example on how to rectify an error and display the error information when you create a bucket that already exists:

    try {
        $ossClient->createBucket($bucket);
    } catch (OssException $e) {
        print("Exception:" . $e->getMessage() . "\n");
    }
            

You can also obtain the following information.

ParameterDescription
HTTPStatusThe HTTP status code. You can obtain the status code by calling getHTTPStatus.
ErrorCodeThe error code returned by OSS. You can obtain the error code by calling getErrorCode.
ErrorMessageThe error message returned by OSS. You can obtain the error message by calling getErrorMessage.
RequestIdThe UUID used to uniquely identify the request. If the problem persists, provide the request ID to OSS developers for help. You can obtain the UUID by calling getRequestId.
DetailsThe error details returned by OSS. You can obtain the error details by calling getDetails.

Common OSS error codes

Error codeDescriptionHTTP status code
AccessDeniedAccess is denied.403
BucketAlreadyExistsThe bucket already exists.409
BucketNotEmptyThe bucket is not empty.409
EntityTooLargeThe entity size exceeds the maximum limit.400
EntityTooSmallThe entity size is below the minimum limit.400
FileGroupTooLargeThe file group size exceeds the maximum limit.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 destination 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
InvalidEncryptionAlgorithmErrorThe encryption algorithm is invalid.400