@Override
  public boolean equals(@Nullable Object obj) {
    if (!(obj instanceof EncodableThrowable)) {
      return false;
    }
    Throwable other = ((EncodableThrowable) obj).throwable;

    // Assuming class preservation is enough to know that serialization/deserialization worked.
    return throwable.getClass().equals(other.getClass());
  }
@Test
  public void testEquals() {
    IllegalStateException exception =
        new IllegalStateException(
            "Some illegal state",
            new RuntimeException(
                "Some nested exception", new Exception("Deeply nested exception")));

    EncodableThrowable comparable1 = EncodableThrowable.forThrowable(exception);
    EncodableThrowable comparable2 = EncodableThrowable.forThrowable(exception);

    assertEquals(comparable1, comparable1);
    assertEquals(comparable1, comparable2);
  }