This document describes exception handling when using the TOS SDK.
TOS Server-Side Error
Custom Exception Handling in SDK
Client Error
Client errors are reported in scenarios such as when incorrect input parameters are provided, or when errors occur that require canceling resumable uploads and similar operations. For example, when creating a bucket, if the bucket name exceeds 63 characters in length, the returned error will have the isClientError parameter set to true, indicating that a client-side error has occurred.
Server-side Error
When a request is sent to the TOS server via the TOS C++ SDK interface, the response includes status codes that comply with HTTP standards as well as business error codes, which indicate the response status of the current request. At the same time, the value of the isClientError parameter is false.
Error Handling Examples
The following code demonstrates how to download an object and handle the return values on the client side. In the event of a server-side error, you can print the HTTP request status code, error message, RequestId, and HostId. If a client-side error occurs, you can print the error message.