public void write(D datum, Encoder out) throws IOException {
    Objects.requireNonNull(out, "Encoder cannot be null");
    try {
      write(root, datum, out);
    } catch (TracingNullPointException | TracingClassCastException | TracingAvroTypeException e) {
      throw e.summarize(root);
    }
  }
@Test
  void unionUnresolvedExceptionExplicitWhichField() throws IOException {
    Schema s = schemaWithExplicitNullDefault();
    GenericRecord r = new GenericData.Record(s);
    r.put("f", 100);
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    try {
      new GenericDatumWriter<>(s).write(r, EncoderFactory.get().jsonEncoder(s, bao));
      fail();
    } catch (final UnresolvedUnionException uue) {
      assertEquals("Not in union [\"null\",\"string\"]: 100 (field=f)", uue.getMessage());
    }
  }