-
Notifications
You must be signed in to change notification settings - Fork 3k
Error Codes
In addition to providing named error strings, Trino 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 |
Thrift | 0x0105 |
Phoenix | 0x0106 |
Kinesis | 0x0200 |
Raptor v1 | 0x0300 |
Raptor v2 | 0x0301 |
Base JDBC | 0x0400 |
Atop | 0x0500 |
Local File | 0x0501 |
Elasticsearch | 0x0503 |
Iceberg | 0x0504 |
Pinot | 0x0505 |
Hudi | 0x0507 |
Google Sheets | 0x0508 |
BigQuery | 0x0509 |
Filesystem Exchange | 0x0510 |
Redshift | 0x0511 |
MongoDB | 0x0512 |
Neo4j | 0x0513 |
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;
}
}