-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Error Codes
David Phillips edited this page Oct 13, 2016
·
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 0x7FF
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 |
Raptor | 0x0300 |
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;
}
}