Java 类com.facebook.presto.spi.ErrorCodeSupplier 实例源码

项目:presto    文件:AbstractTestFunctions.java   
protected void assertInvalidFunction(String projection, ErrorCodeSupplier expectedErrorCode)
{
    try {
        evaluateInvalid(projection);
        fail(format("Expected to throw %s exception", expectedErrorCode.toErrorCode()));
    }
    catch (PrestoException e) {
        assertEquals(e.getErrorCode(), expectedErrorCode.toErrorCode());
    }
}
项目:presto    文件:TestLocalExecutionPlanner.java   
private void assertFails(@Language("SQL") String sql, ErrorCodeSupplier supplier)
{
    try {
        runner.execute(sql);
        fail("expected exception");
    }
    catch (PrestoException e) {
        assertEquals(e.getErrorCode(), supplier.toErrorCode());
    }
}
项目:presto    文件:Types.java   
public static <A, B extends A> B checkType(A value, Class<B> target, ErrorCodeSupplier errorCode, String name)
{
    if (value == null) {
        throw new NullPointerException(format("%s is null", name));
    }
    if (!target.isInstance(value)) {
        throw new PrestoException(errorCode, format(
                "%s must be of type %s, not %s",
                name,
                target.getName(),
                value.getClass().getName()));
    }
    return target.cast(value);
}
项目:presto    文件:Failures.java   
public static void checkCondition(boolean condition, ErrorCodeSupplier errorCode, String formatString, Object... args)
{
    if (!condition) {
        throw new PrestoException(errorCode, format(formatString, args));
    }
}
项目:presto    文件:HiveUtil.java   
public static void checkCondition(boolean condition, ErrorCodeSupplier errorCode, String formatString, Object... args)
{
    if (!condition) {
        throw new PrestoException(errorCode, format(formatString, args));
    }
}