All Products
Search
Document Center

Lindorm:Handle exceptions

Last Updated:Sep 07, 2022

This topic describes how to configure your application to handle exceptions that are thrown by Lindorm TSDB SDK. 

Lindorm TSDB SDK throws ClientExceptions and LindormTSDBExceptions. ClientExceptions are related to the client and LindormTSDBExceptions are related to the server. Both types of exceptions belong to RuntimeExceptions. 

ClientException

A ClientException is an exception that is thrown when a client sends a request or transmits data to the Lindorm time series engine. For example, a ClientException is thrown if a request is sent in poor network conditions. 

LindormTSDBException

A LindormTSDBException is a server exception. A LindormTSDBException contains the error code and error message that are returned by the Lindorm time series engine. You can use the information to identify the cause and then handle the exception. The following table describes the information that is included in a LindormTSDBException in common usage scenarios.

Parameter

Description

code

The error code that is returned by the Lindorm time series engine. 

sqlstate

The sqlstate value that is returned by the Lindorm time series engine. 

message

The error message that is returned by the Lindorm time series engine. 

Note

For more information about the error messages that are returned by the Lindorm time series engine, see Common error codes

Example

The following code block shows how to handle exceptions:

try {
    // The operation that is performed by Lindorm TSDB SDK, such as a query.
    lindormTSDBClient.query(....);
} catch (LindormTSDBException e) {
    System.out.println("Caught an LindormTSDBException, which means your request made it to Lindrom TSDB, "
            + "but was rejected with an error response for some reason.");
    // For more information about the error codes and error messages, visit https://https://www.alibabacloud.com/help/en/apsaradb-for-lindorm/latest/common-error-codes-reference
    System.out.println("Error Code: " + e.getCode());
    System.out.println("SQL State:  " + e.getSqlstate());
    System.out.println("Error Message: " + e.getMessage());
} catch(ClientException ce) {
    System.out.println("Caught an ClientException, which means the client encountered "
            + "a serious internal problem while trying to communicate with Lindorm TSDB, "
            + "such as not being able to access the network.");
    System.out.println("Error Message: " + ce.getMessage());
}