public void testExceptionConversion() { Exception ex1 = createException(); ex1.initCause(createSimpleCause()); Throwable ex = HiveSQLException.toCause(HiveSQLException.toString(ex1)); Assert.assertSame(RuntimeException.class, ex.getClass()); Assert.assertEquals("exception1", ex.getMessage()); Assert.assertSame(UnsupportedOperationException.class, ex.getCause().getClass()); Assert.assertEquals("exception2", ex.getCause().getMessage()); } };
/** * Tests the conversion of the exception that the class type of one of the causes * doesn't exist. The stack trace text is generated on the server and passed to JDBC * client. It's possible that some cause types don't exist on the client and HiveSQLException * can't convert them and use RunTimeException instead. */ @Test public void testExceptionWithMissingTypeOnClient() { Exception ex1 = new UnsupportedOperationException(); ex1.initCause(createSimpleCause()); List<String> details = HiveSQLException.toString(ex1); // Simulate an unknown type String[] tokens = details.get(0).split(":"); tokens[0] = "*DummyException"; details.set(0, StringUtils.join(tokens, ":")); Throwable ex = HiveSQLException.toCause(details); Assert.assertEquals(RuntimeException.class, ex.getClass()); }
/** * Tests the conversion between the exception text with nested cause and * the Throwable object */ @Test public void testNestedException() { Exception ex1 = createException(); ex1.initCause(createNestedCause()); Throwable ex = HiveSQLException.toCause(HiveSQLException.toString(ex1)); Assert.assertSame(RuntimeException.class, ex.getClass()); Assert.assertEquals("exception1", ex.getMessage()); Assert.assertSame(UnsupportedOperationException.class, ex.getCause().getClass()); Assert.assertEquals("exception2", ex.getCause().getMessage()); Assert.assertSame(Exception.class, ex.getCause().getCause().getClass()); Assert.assertEquals("exception3", ex.getCause().getCause().getMessage()); }
/** * Tests the conversion of the exception with unknown source */ @Test public void testExceptionWithUnknownSource() { Exception ex1 = createException(); ex1.initCause(createSimpleCause()); List<String> details = HiveSQLException.toString(ex1); // Simulate the unknown source String[] tokens = details.get(1).split(":"); tokens[2] = null; tokens[3] = "-1"; details.set(1, StringUtils.join(tokens, ":")); Throwable ex = HiveSQLException.toCause(details); Assert.assertSame(RuntimeException.class, ex.getClass()); Assert.assertEquals("exception1", ex.getMessage()); Assert.assertSame(UnsupportedOperationException.class, ex.getCause().getClass()); Assert.assertEquals("exception2", ex.getCause().getMessage()); }
/** * Tests the conversion between the exception text with the simple cause and the * Throwable object */ @Test public void testExceptionMarshalling() throws Exception { Exception ex1 = createException(); ex1.initCause(createSimpleCause()); Throwable ex = HiveSQLException.toCause(HiveSQLException.toString(ex1)); Assert.assertSame(RuntimeException.class, ex.getClass()); Assert.assertEquals("exception1", ex.getMessage()); Assert.assertSame(UnsupportedOperationException.class, ex.getCause().getClass()); Assert.assertEquals("exception2", ex.getCause().getMessage()); }
public HiveSQLException(TStatus status) { // TODO: set correct vendorCode field super(status.getErrorMessage(), status.getSqlState(), status.getErrorCode()); if (status.getInfoMessages() != null) { initCause(toCause(status.getInfoMessages())); } }
public HiveSQLException(TStatus status) { // TODO: set correct vendorCode field super(status.getErrorMessage(), status.getSqlState(), status.getErrorCode()); if (status.getInfoMessages() != null) { initCause(toCause(status.getInfoMessages())); } }
public HiveSQLException(TStatus status) { // TODO: set correct vendorCode field super(status.getErrorMessage(), status.getSqlState(), status.getErrorCode()); if (status.getInfoMessages() != null) { initCause(toCause(status.getInfoMessages())); } }
public HiveSQLException(TStatus status) { // TODO: set correct vendorCode field super(status.getErrorMessage(), status.getSqlState(), status.getErrorCode()); if (status.getInfoMessages() != null) { initCause(toCause(status.getInfoMessages())); } }
public HiveSQLException(TStatus status) { // TODO: set correct vendorCode field super(status.getErrorMessage(), status.getSqlState(), status.getErrorCode()); if (status.getInfoMessages() != null) { initCause(toCause(status.getInfoMessages())); } }
public HiveSQLException(TStatus status) { // TODO: set correct vendorCode field super(status.getErrorMessage(), status.getSqlState(), status.getErrorCode()); if (status.getInfoMessages() != null) { initCause(toCause(status.getInfoMessages())); } }