Error handling

更新时间:
复制 MD 格式

The Tablestore .NET SDK handles errors by throwing exceptions. This topic describes the error handling method, exception information, and retry policies.

Method

The Tablestore .NET SDK handles errors by throwing exceptions. If an API call does not throw an exception, the operation is successful. Otherwise, the operation failed.

Note

For batch operations, such as BatchGetRow and BatchWriteRow, you must check for exceptions and verify the status of each row. The entire API call is considered successful only if all rows are processed successfully.

Exceptions

The Tablestore .NET SDK provides two types of exceptions: OTSClientException and OTSServerException. Both exceptions inherit from the base Exception class.

  • OTSClientException: Indicates an internal SDK error, such as an incorrect parameter setting or a failure to parse a result.

  • OTSServerException: Indicates a server-side error that is thrown after the SDK parses an error message from the server. An OTSServerException object typically contains the following members:

    • HttpStatusCode: The HTTP status code, such as 200 or 404.

    • ErrorCode: The error code string returned by Tablestore.

    • ErrorMessage: The error message string returned by Tablestore.

    • RequestId: The Universally Unique Identifier (UUID) that uniquely identifies the request. If you cannot resolve an issue, record this RequestId and submit a ticketor join DingTalk group 36165029092 (Tablestore Technical Support Group 3) for assistance.

Retries

  • The SDK automatically retries operations when an error occurs. The default retry policy is to retry an operation a maximum of three times with a maximum retry interval of 2000 ms. For more information, see Retry.

  • You can also customize the retry policy by modifying the RetryPolicy parameter in OTSClientConfig.