@Override public final void write(E entity) { Preconditions.checkState( state.equals(ReaderWriterState.OPEN), "Attempt to write to a writer in state:%s", state); try { appender.append(entity); count += 1; } catch (IOException e) { this.state = ReaderWriterState.ERROR; throw new DatasetIOException("Failed to append " + entity + " to " + appender, e); } }
@Override public final void write(E entity) { Preconditions.checkState( state.equals(ReaderWriterState.OPEN), "Attempt to write to a writer in state:%s", state); try { appender.append(entity); count += 1; } catch (RuntimeException e) { Throwables.propagateIfInstanceOf(e, DatasetRecordException.class); this.state = ReaderWriterState.ERROR; throw new DatasetOperationException(e, "Failed to append %s to %s", entity, appender); } catch (IOException e) { this.state = ReaderWriterState.ERROR; throw new DatasetIOException("Failed to append " + entity + " to " + appender, e); } }