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.
|
|
HTTPStatus |
|
ErrorCode |
|
ErrorMessage |
|
RequestId |
|
Details |
|
Common OSS error codes
|
|
|
AccessDenied |
| 403 |
BucketAlreadyExists |
| 409 |
BucketNotEmpty |
| 409 |
EntityTooLarge |
| 400 |
EntityTooSmall |
| 400 |
FileGroupTooLarge |
| 400 |
FilePartNotExist |
| 400 |
FilePartStale |
| 400 |
InvalidArgument |
| 400 |
InvalidAccessKeyId |
| 403 |
InvalidBucketName |
| 400 |
InvalidDigest |
| 400 |
InvalidObjectName |
| 400 |
InvalidPart |
| 400 |
InvalidPartOrder |
| 400 |
InvalidTargetBucketForLogging |
| 400 |
InternalError |
| 500 |
MalformedXML |
| 400 |
MethodNotAllowed |
| 405 |
MissingArgument |
| 411 |
MissingContentLength |
| 411 |
NoSuchBucket |
| 404 |
NoSuchKey |
| 404 |
NoSuchUpload |
| 404 |
NotImplemented |
| 501 |
PreconditionFailed |
| 412 |
RequestTimeTooSkewed |
| 403 |
RequestTimeout |
| 400 |
SignatureDoesNotMatch |
| 403 |
InvalidEncryptionAlgorithmError |
| 400 |