Baidu AI Cloud
中国站

百度智能云

Object Storage

Exception Handling

BOS exception is prompted in the following 4 ways:

Exception method Description
BceBaseException Anthology of exceptions
BceClientException Client exception
BceServerException Server exception
InvalidArgumentException System built-in exception, parameter error

You can use try to get exceptions generated by an event:

try {
    $client->deleteObject($bucketName, $objectKey);
} catch (\BaiduBce\Exception\BceBaseException $e) {
    print $e->getMessage();
    if (strcmp(get_class($e), "BaiduBce\Exception\BceClientException") == 0) {
        print "Catch a client exception";
    }
    if (strcmp(get_class($e), "BaiduBce\Exception\BceServiceException") == 0) {
        print "Catch a server exception";
    }
    if (strcmp(get_class($e), "BaiduBce\Exception\BceBaseException") == 0) {
        print "Catch a base exception";
    }
    if (strcmp(get_class($e), "BaiduBce\Exception\InvalidArgumentException") == 0) {
        print "Catch a invalid argument exception";
    }
};

Client Exception

Client exception indicates an exception encountered when the client attempts to send a request to the BOS and transmits data. For example, when the network connection is unavailable at the time of sending request, ClientException is returned; and in case of IO exception during file upload, ClientException is also thrown.

Server Exception

When an exception occurs on the BOS server, the BOS server returns the corresponding error message to the user to locate the problem. Common server exceptions can be found in BOS Error Message Format.

Previous
File Management
Next
Version Change Record