Error handling
Updated at:2025-11-11
The Go language uses the error type to identify errors. CFS supports two types of errors as shown in the table below:
| Error type | Description |
|---|---|
| BceClientError | Errors caused by user operations |
| BceServiceError | Errors returned by the CFS service |
When users call CFS-related APIs using the SDK, in addition to the required results, errors may also be returned. These errors can be retrieved and handled by users. An example is given below:
Plain Text
1// cfsClient is the created CFS Client object
2describeArgs := &DescribeFSArgs {
3 FSID: CFS_ID,
4}
5cfsDetail, err := cfsClient.DescribeFS(describeArgs)
6if err != nil {
7 switch realErr := err.(type) {
8 case *bce.BceClientError:
9 fmt.Println("client occurs error:", realErr.Error())
10 case *bce.BceServiceError:
11 fmt.Println("service occurs error:", realErr.Error())
12 default:
13 fmt.Println("unknown error:", err)
14 }
15} else {
16 fmt.Println("get cfs detail success: ", cfsDetail)
17}
Client exception
A client exception occurs when there are issues with sending requests or transferring data between the client and CFS. For instance, if the network connection is unavailable while sending a request, a BceClientError will be returned.
Server exception
A server exception occurs when there are errors on the CFS server side. The service provides detailed error messages to help with troubleshooting.
