@Test
  public void testExceptionToTStatus() {
    Exception ex1 = createException();
    ex1.initCause(createSimpleCause());
    TStatus status = HiveSQLException.toTStatus(ex1);

    Assert.assertEquals(TStatusCode.ERROR_STATUS, status.getStatusCode());
    Assert.assertEquals(ex1.getMessage(), status.getErrorMessage());
    Assert.assertEquals(HiveSQLException.DEFAULT_INFO, status.getInfoMessages());
  }
Tests the conversion from a regular exception to the TStatus object
service/src/test/org/apache/hive/service/cli/TestHiveSQLException.java