use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.
the class TestUserException method testBuildSystemException.
// make sure system exceptions are created properly
@Test
public void testBuildSystemException() {
String message = "This is an exception";
UserException uex = UserException.systemError(new Exception(new RuntimeException(message))).build(logger);
Assert.assertTrue(uex.getOriginalMessage().contains(message));
Assert.assertTrue(uex.getOriginalMessage().contains("RuntimeException"));
DrillPBError error = uex.getOrCreatePBError(true);
Assert.assertEquals(ErrorType.SYSTEM, error.getErrorType());
}
use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.
the class TestUserException method testBuildUserExceptionWithFormattedMessage.
@Test
public void testBuildUserExceptionWithFormattedMessage() {
String format = "This is test #%d";
UserException uex = UserException.connectionError().message(format, 5).build(logger);
DrillPBError error = uex.getOrCreatePBError(false);
Assert.assertEquals(ErrorType.CONNECTION, error.getErrorType());
Assert.assertEquals(String.format(format, 5), uex.getOriginalMessage());
}
use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.
the class TestUserException method testBuildUserExceptionWithUserExceptionCauseAndMessage.
@Test
public void testBuildUserExceptionWithUserExceptionCauseAndMessage() {
String messageA = "Test message A";
String messageB = "Test message B";
UserException original = UserException.connectionError().message(messageA).build(logger);
UserException uex = UserException.dataWriteError(wrap(original, 5)).message(messageB).build(logger);
// builder should return the unwrapped original user exception and not build a new one
Assert.assertEquals(original, uex);
DrillPBError error = uex.getOrCreatePBError(false);
Assert.assertEquals(messageA, uex.getOriginalMessage());
// messageB should not be part of the context
Assert.assertFalse(error.getMessage().contains(messageB));
}
Aggregations