public void testNotSerializableExceptionWrapper() throws IOException {
    NotSerializableExceptionWrapper ex =
        serialize(new NotSerializableExceptionWrapper(new NullPointerException()));
    assertEquals("{\"type\":\"null_pointer_exception\",\"reason\":null}", toXContent(ex));
    ex = serialize(new NotSerializableExceptionWrapper(new IllegalArgumentException("nono!")));
    assertEquals("{\"type\":\"illegal_argument_exception\",\"reason\":\"nono!\"}", toXContent(ex));

    Throwable[] unknowns =
        new Throwable[] {
          new JsonParseException("foobar", new JsonLocation(new Object(), 1, 2, 3, 4)),
          new GroovyCastException("boom boom boom"),
          new IOException("booom")
        };
    for (Throwable t : unknowns) {
      if (randomBoolean()) {
        t.addSuppressed(new IOException("suppressed"));
        t.addSuppressed(new NullPointerException());
      }
      Throwable deserialized = serialize(t);
      assertTrue(deserialized instanceof NotSerializableExceptionWrapper);
      assertArrayEquals(t.getStackTrace(), deserialized.getStackTrace());
      assertEquals(t.getSuppressed().length, deserialized.getSuppressed().length);
      if (t.getSuppressed().length > 0) {
        assertTrue(deserialized.getSuppressed()[0] instanceof NotSerializableExceptionWrapper);
        assertArrayEquals(
            t.getSuppressed()[0].getStackTrace(), deserialized.getSuppressed()[0].getStackTrace());
        assertTrue(deserialized.getSuppressed()[1] instanceof NullPointerException);
      }
    }
  }