Baidu AI Cloud
中国站

百度智能云

Object Storage

Exception Handling

BOS exceptions are prompted in the following two methods:

Exception method Description
BceClientException Client exception
BceServerException Server exception

Users can obtain the exception generated by an event with try, for example:

String objectKey = "testObjectToFile";
    bosclient.putObject(bucketName, objectKey, "dataFile");
      File file = new File("test");

        try {
            bosclient.getObject(this.bucketName, objectKey, file);
        } catch (BceServerException bce){
            System.out.println(bce.getMessage());
        } catch ( BceClientException bce){
            System.out.println( bce.getMessage());
        } finally {
            file.delete();
        }

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
Data Processing and Use
Next
sdk Log