protected boolean matchesSafely()

in future/src/main/java/com/spotify/hamcrest/future/ExceptionallyCompletedBlockingCompletionStage.java [46:69]


  protected boolean matchesSafely(
      final CompletionStage<?> stage, final Description mismatchDescription) {
    try {
      final Object item = stage.toCompletableFuture().get();
      mismatchDescription
          .appendText("a stage that completed with a value that was ")
          .appendValue(item);
      return false;
    } catch (InterruptedException e) {
      mismatchDescription.appendText("a stage that was interrupted");
      return false;
    } catch (CancellationException e) {
      mismatchDescription.appendText("a stage that was cancelled");
      return false;
    } catch (ExecutionException e) {
      if (matcher.matches(e.getCause())) {
        return true;
      } else {
        mismatchDescription.appendText("a stage completed exceptionally with ");
        matcher.describeMismatch(e.getCause(), mismatchDescription);
        return false;
      }
    }
  }