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.
Parameter | Description |
---|---|
HTTPStatus | The HTTP status code. You can obtain the status code by calling getHTTPStatus. |
ErrorCode | The error code returned by OSS. You can obtain the error code by calling getErrorCode. |
ErrorMessage | The error message returned by OSS. You can obtain the error message by calling getErrorMessage. |
RequestId | The 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. |
Details | The error details returned by OSS. You can obtain the error details by calling getDetails. |
Common OSS error codes
Error code | Description | 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 destination 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 |
InvalidEncryptionAlgorithmError | The encryption algorithm is invalid. | 400 |