public Protobuf2 writeTo(Message msg, OutputStream output) {
    try {
      msg.writeTo(output);
    } catch (IOException e) {
      throw new IllegalStateException("Can not write message " + msg, e);
    }
    return this;
  }
@Test
  public void writeTo_throws_ISE_on_error() throws Exception {
    try (FailureOutputStream output = new FailureOutputStream()) {
      assertThatThrownBy(() -> underTest.writeTo(newMetadata(PROJECT_KEY_1), output))
        .isInstanceOf(IllegalStateException.class)
        .hasMessageContaining("Can not write message");
    }
  }