Fill in suppressed exceptions in assertInvalid* functions
@@ -135,9 +135,15 @@ public abstract class AbstractTestFunctions
fail("Expected to throw a PrestoException with message matching " + messagePattern);
}
catch (PrestoException e) {
+ try {
assertEquals(e.getErrorCode(), errorCode.toErrorCode());
assertTrue(e.getMessage().equals(messagePattern) || e.getMessage().matches(messagePattern));
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
protected void assertInvalidFunction(String projection, String messagePattern)
@@ -152,8 +158,14 @@ public abstract class AbstractTestFunctions
fail(format("Expected to throw %s exception", expectedErrorCode));
}
catch (SemanticException e) {
+ try {
assertEquals(e.getCode(), expectedErrorCode);
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
protected void assertInvalidFunction(String projection, SemanticErrorCode expectedErrorCode, String message)
@@ -163,9 +175,15 @@ public abstract class AbstractTestFunctions
fail(format("Expected to throw %s exception", expectedErrorCode));
}
catch (SemanticException e) {
+ try {
assertEquals(e.getCode(), expectedErrorCode);
assertEquals(e.getMessage(), message);
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
protected void assertInvalidFunction(String projection, ErrorCodeSupplier expectedErrorCode)
@@ -175,8 +193,14 @@ public abstract class AbstractTestFunctions
fail(format("Expected to throw %s exception", expectedErrorCode.toErrorCode()));
}
catch (PrestoException e) {
+ try {
assertEquals(e.getErrorCode(), expectedErrorCode.toErrorCode());
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
protected void assertNumericOverflow(String projection, String message)
@@ -186,9 +210,15 @@ public abstract class AbstractTestFunctions
fail("Expected to throw an NUMERIC_VALUE_OUT_OF_RANGE exception with message " + message);
}
catch (PrestoException e) {
+ try {
assertEquals(e.getErrorCode(), NUMERIC_VALUE_OUT_OF_RANGE.toErrorCode());
assertEquals(e.getMessage(), message);
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
protected void assertInvalidCast(String projection)
@@ -198,8 +228,14 @@ public abstract class AbstractTestFunctions
fail("Expected to throw an INVALID_CAST_ARGUMENT exception");
}
catch (PrestoException e) {
+ try {
assertEquals(e.getErrorCode(), INVALID_CAST_ARGUMENT.toErrorCode());
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
protected void assertInvalidCast(String projection, String message)
@@ -209,9 +245,15 @@ public abstract class AbstractTestFunctions
fail("Expected to throw an INVALID_CAST_ARGUMENT exception");
}
catch (PrestoException e) {
+ try {
assertEquals(e.getErrorCode(), INVALID_CAST_ARGUMENT.toErrorCode());
assertEquals(e.getMessage(), message);
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
public void assertCachedInstanceHasBoundedRetainedSize(String projection)
@@ -226,9 +268,15 @@ public abstract class AbstractTestFunctions
fail("expected exception");
}
catch (PrestoException e) {
+ try {
assertEquals(e.getErrorCode(), NOT_SUPPORTED.toErrorCode());
assertEquals(e.getMessage(), message);
}
+ catch (Throwable failure) {
+ failure.addSuppressed(e);
+ throw failure;
+ }
+ }
}
protected void tryEvaluateWithAll(String projection, Type expectedType)
