Baidu AI Cloud
中国站

百度智能云

Object Storage

Error Processing

GO language marks error with error type, and BOS supports 2 errors in the table below:

Error type Description
BceClientError Error arising from user operation
BceServiceError Error returned by BOS service

You call BOS related interface with SDK, in addition to the results required, error is returned, and users can get relevant errors for handling. Instance is as follows"

// BosClient is a created BOS Client object. 
bucketLocation, err := bosClient.Putbucket("test-bucket") 
if err != nil { 
	 switch realErr := err.(type) { 
	 case *bce.BceClientError: 
	 	 fmt.Println("client occurs error:", realErr.Error()) 
	 case *bce.BceServiceError: 
	 	 fmt.Println("service occurs error:", realErr.Error()) 
	 default: 
	 	 fmt.Println("unknown error:", err) 
	 } 
} else { 
	 fmt.Println("create bucket success, bucket location:", bucketLocation) 
} 

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, BceClientError is returned; and in case of IO exception during file upload, BceClientError 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