Exception Handling
Last Updated:2020-07-20
BOS exceptions are prompted in the following two methods:
Exception method | Description |
---|---|
BceClientException | Client exception |
BceServerException | Server exception |
You can use try to get exceptions generated by an event.
-
Sample Code
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("Error ErrorCode: " + e.getErrorCode()); System.out.println("Error RequestId: " + e.getRequestId()); System.out.println("Error StatusCode: " + e.getStatusCode()); System.out.println("Error ErrorType: " + e.getErrorType()); System.out.println("Error Message: " + e.getMessage()); } catch ( BceClientException bce){ System.out.println( bce.getMessage()); } finally { file.delete(); }