use of org.apache.phoenix.exception.SQLExceptionCode in project phoenix by apache.
the class SchemaUtilTest method testExceptionCode.
@Test
public void testExceptionCode() throws Exception {
SQLExceptionCode code = SQLExceptionCode.fromErrorCode(SQLExceptionCode.AGGREGATE_IN_GROUP_BY.getErrorCode());
assertEquals(SQLExceptionCode.AGGREGATE_IN_GROUP_BY, code);
}
use of org.apache.phoenix.exception.SQLExceptionCode in project phoenix by apache.
the class Sequence method incrementValue.
public long incrementValue(Result result, ValueOp op, long numToAllocate) throws SQLException {
// before a next val was. Not sure how to prevent that.
if (result.rawCells().length == 1) {
Cell errorKV = result.rawCells()[0];
int errorCode = PInteger.INSTANCE.getCodec().decodeInt(errorKV.getValueArray(), errorKV.getValueOffset(), SortOrder.getDefault());
SQLExceptionCode code = SQLExceptionCode.fromErrorCode(errorCode);
// }
throw new SQLExceptionInfo.Builder(code).setSchemaName(key.getSchemaName()).setTableName(key.getSequenceName()).build().buildException();
}
// If we found the sequence, we update our cache with the new value
SequenceValue value = new SequenceValue(result, op, numToAllocate);
insertSequenceValue(value);
return increment(value, op, numToAllocate);
}
use of org.apache.phoenix.exception.SQLExceptionCode in project phoenix by apache.
the class ServerUtil method parseRemoteException.
private static SQLException parseRemoteException(Throwable t) {
String message = t.getLocalizedMessage();
if (message != null) {
// If the message matches the standard pattern, recover the SQLException and throw it.
Matcher matcher = PATTERN.matcher(t.getLocalizedMessage());
if (matcher.find()) {
int statusCode = Integer.parseInt(matcher.group(1));
SQLExceptionCode code = SQLExceptionCode.fromErrorCode(statusCode);
return new SQLExceptionInfo.Builder(code).setMessage(matcher.group()).setRootCause(t).build().buildException();
}
}
return null;
}
Aggregations