Exception Handling
Last Updated:2020-07-20
BOS exceptions are prompted in the following two methods:
Exception method | Description |
---|---|
BceClientException | Client exception |
BceServiceException | 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 (BceServiceException bce){
System.out.println(bce.getMessage());
} catch ( BceClientException bce){
System.out.println( bce.getMessage());
} finally {
file.delete();
}