Exception handling
Updated at:2025-11-03
BOS exception prompts are available in the following two ways:
| Exception type | Description |
|---|---|
| BceClientException | Client exception |
| BceServiceException | Server exception |
Users can use try to obtain the exception generated by a certain event, e.g.:
Java
1String objectKey = "testObjectToFile";
2bosclient.putObject(bucketName, objectKey, "dataFile");
3File file = new File("test");
4try {
5 bosclient.getObject(this.bucketName, objectKey, file);
6} catch (BceServiceException bce){
7 System.out.println(bce.getMessage());
8} catch ( BceClientException bce){
9 System.out.println( bce.getMessage());
10} finally {
11 file.delete();
12}
Client exception
A client exception occurs when the client encounters issues while sending requests or transmitting data to BOS. For example, ClientException is thrown for network failures or I/O errors during file uploads.
Server exception
A server exception is generated when BOS server-side errors occur. The service returns detailed error messages to assist troubleshooting. For common server exceptions, refer to [BOS Error Message Format](BOS/API Reference/Error code.md)
