public static boolean containsMessage(@Nullable Throwable exception, String message) {
    if (exception == null) {
      return false;
    }

    if (exception.getMessage() != null && exception.getMessage().contains(message)) {
      return true;
    }

    return containsMessage(exception.getCause(), message);
  }
@Test
  public void testContainsNegativeWithNested() {
    assertThat(
            containsMessage(
                new IllegalStateException(
                    "There is a bad state in the client",
                    new IllegalArgumentException("RESOURCE_EXHAUSTED: Quota issues")),
                "401 Unauthorized"))
        .isFalse();
  }