-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Error Codes
Dain Sundstrom edited this page Jun 10, 2017
·
18 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.
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 |
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;
}
}