public static <T extends Throwable> org.hamcrest.Matcher<T> hasMessage(String expectedMessage) {
        return new ThrowableMessageMatcher<>(expectedMessage);
    }
public static < T extends Throwable > org . hamcrest . Matcher < T > hasMessage ( String expectedMessage ) { return new ThrowableMessageMatcher < > ( expectedMessage ) ; }
EXAMPLE:
<code>assertThat(caughtThrowable(), hasMessage("Index: 9, Size: 9"));</code>

@param <T>
the throwable subclass
@param expectedMessage
the expected throwable message
@return Returns a matcher that matches an throwable if it has the given message.