Skip to content

Error Codes

Wenlei Xie edited this page Aug 10, 2020 · 17 revisions

In addition to providing named error strings, Presto maps error codes onto integers for use with APIs like JDBC's SQLException that require an integer.

Each connector is allocated its own 16-bit range of error codes, indicated in the table below. New allocations may be reserved by adding them to the table. In this document, a range such as 0x1234 represents 0x12340000 to 0x1234FFFF.

The range 0x00FF is reserved for use in clients (such as JDBC) to return client-side errors to applications. Error codes in this range will never be returned from the server.

Additionally, the range 0x7F00 to 0x7FFF is reserved for private connectors. This is useful for connectors that are private to an organization (and thus will not conflict with other private connectors in other organizations).

Connector Error Code Range
Hive 0x0100
Decoder 0x0101
Kafka 0x0102
Accumulo 0x0103
Cassandra 0x0104
ThriftConnector 0x0105
Raptor v1 0x0300
Raptor v2 0x0301
Base JDBC 0x0400
Atop 0x0500
Local File 0x0501
Memory 0x0502
Elasticsearch 0x0503
Pinot 0x0505
Druid 0x0506
Parquet 0x0605

The following code shows the recommended way for a connector to implement error codes. In this example, the connector is allocated range 0x1234:

public enum ExampleErrorCode
        implements ErrorCodeSupplier
{
    EXAMPLE_ERROR(0),
    ANOTHER_EXAMPLE_ERROR(1);

    private final ErrorCode errorCode;

    ExampleErrorCode(int code)
    {
        errorCode = new ErrorCode(code + 0x1234_0000, name());
    }

    @Override
    public ErrorCode toErrorCode()
    {
        return errorCode;
    }
}
Clone this wiki locally