### Question:
LeveldbIterator implements Iterator<Map.Entry<byte[], byte[]>>,
                                        Closeable { @Override public void close() throws IOException { try { iter.close(); } catch (RuntimeException e) { throw new IOException(e.getMessage(), e); } } LeveldbIterator(DB db);  LeveldbIterator(DB db, ReadOptions options);  LeveldbIterator(DBIterator iter); void seek(byte[] key); void seekToFirst(); void seekToLast(); boolean hasNext(); @Override Map.Entry<byte[], byte[]> next(); Map.Entry<byte[], byte[]> peekNext(); boolean hasPrev(); Map.Entry<byte[], byte[]> prev(); Map.Entry<byte[], byte[]> peekPrev(); @Override void remove(); @Override void close();  }### Answer:
@Test public void testExceptionHandling() throws Exception { InvocationHandler rtExcHandler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { throw new RuntimeException("forced runtime error"); } }; DBIterator dbiter = (DBIterator) Proxy.newProxyInstance( DBIterator.class.getClassLoader(), new Class[] { DBIterator.class }, rtExcHandler); LeveldbIterator iter = new LeveldbIterator(dbiter); for (CallInfo ci : RTEXC_METHODS) { Method method = iter.getClass().getMethod(ci.methodName, ci.argTypes); assertNotNull("unable to locate method " + ci.methodName, method); try { method.invoke(iter, ci.args); fail("operation should have thrown"); } catch (InvocationTargetException ite) { Throwable exc = ite.getTargetException(); assertTrue("Method " + ci.methodName + " threw non-DBException: " + exc, exc instanceof DBException); assertFalse("Method " + ci.methodName + " double-wrapped DBException", exc.getCause() instanceof DBException); } } try { iter.close(); fail("operation shoul have thrown"); } catch (IOException e) { } }