Produce { public @Nullable E getError() { return error != null ? error.get() : null; } private  Produce(T result, Supplier<E> error);  Produce(T result);  Produce(Supplier<E> error); void ifPresent(Consumer<T> consumer); boolean hasResult(); boolean hasError(); @Nullable E getError(); T getResult();  }
@Test void getError() { Assertions.assertEquals(WITHOUT_RESULT.getError(), "error"); Assertions.assertNull(WITH_RESULT.getError()); }