@Test public void testTransactionThrowsRuntimeException() { given(block.value(transaction)).willThrow(new RuntimeException("test", null)); CatchException.verifyException(transaction, DatabaseException.class).transaction(block); }
@Override public Object transaction(Block block) { Handle handle = null; try { handle = getHandle(); begin(handle); Object value = block.value(this); commit(handle); return value; } catch (WasabiException | IllegalArgumentException e) { LOGGER.warn("Problem executing block. Trying to rollback...", e); rollback(handle); throw e; } catch (Exception e) { LOGGER.warn("Unexpected exception executing block. Trying to rollback...", e); rollback(handle); throw new DatabaseException("Unexpected exception when executing block \"" + block + "\"", e); } finally { close(handle); } }
DBITransaction implements Transaction { @Override public Object transaction(Block block) { Handle handle = null; try { handle = getHandle(); begin(handle); Object value = block.value(this); commit(handle); return value; } catch (WasabiException | IllegalArgumentException e) { LOGGER.warn("Problem executing block. Trying to rollback...", e); rollback(handle); throw e; } catch (Exception e) { LOGGER.warn("Unexpected exception executing block. Trying to rollback...", e); rollback(handle); throw new DatabaseException("Unexpected exception when executing block \"" + block + "\"", e); } finally { close(handle); } } }
DBITransaction implements Transaction { @Override public Object transaction(Block block) { Handle handle = null; try { handle = getHandle(); begin(handle); Object value = block.value(this); commit(handle); return value; } catch (WasabiException | IllegalArgumentException e) { LOGGER.warn("Problem executing block. Trying to rollback...", e); rollback(handle); throw e; } catch (Exception e) { LOGGER.warn("Unexpected exception executing block. Trying to rollback...", e); rollback(handle); throw new DatabaseException("Unexpected exception when executing block \"" + block + "\"", e); } finally { close(handle); } } DBITransaction(DBI dbi); }
DBITransaction implements Transaction { @Override public Object transaction(Block block) { Handle handle = null; try { handle = getHandle(); begin(handle); Object value = block.value(this); commit(handle); return value; } catch (WasabiException | IllegalArgumentException e) { LOGGER.warn("Problem executing block. Trying to rollback...", e); rollback(handle); throw e; } catch (Exception e) { LOGGER.warn("Unexpected exception executing block. Trying to rollback...", e); rollback(handle); throw new DatabaseException("Unexpected exception when executing block \"" + block + "\"", e); } finally { close(handle); } } DBITransaction(DBI dbi); @Override Object transaction(Block block); @Override S attach(Class<S> transactional); @Override List select(final String query, final Object... params); @Override void insert(final String query, final Object... params); @Override Integer insertAndReturnKey(final String query, final Object... params); @Override Integer update(final String query, final Object... params); void close(Handle handle); }
DBITransaction implements Transaction { @Override public Object transaction(Block block) { Handle handle = null; try { handle = getHandle(); begin(handle); Object value = block.value(this); commit(handle); return value; } catch (WasabiException | IllegalArgumentException e) { LOGGER.warn("Problem executing block. Trying to rollback...", e); rollback(handle); throw e; } catch (Exception e) { LOGGER.warn("Unexpected exception executing block. Trying to rollback...", e); rollback(handle); throw new DatabaseException("Unexpected exception when executing block \"" + block + "\"", e); } finally { close(handle); } } DBITransaction(DBI dbi); @Override Object transaction(Block block); @Override S attach(Class<S> transactional); @Override List select(final String query, final Object... params); @Override void insert(final String query, final Object... params); @Override Integer insertAndReturnKey(final String query, final Object... params); @Override Integer update(final String query, final Object... params); void close(Handle handle);  }