package com.github.kokorin.jaffree;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;

public class StackTraceMatcher extends BaseMatcher<Object> {
    private final String messagePart;

    public StackTraceMatcher(String messagePart) {
        this.messagePart = messagePart;
    }

    @Override
    public boolean matches(Object item) {
        if (!(item instanceof Throwable)) {
            return false;
        }

        Throwable throwable = (Throwable) item;
        while (throwable != null) {
            String message = throwable.getMessage();
            if (message != null && message.contains(messagePart)) {
                return true;
            }
            throwable = throwable.getCause();
        }

        return false;
    }

    @Override
    public void describeTo(Description description) {

    }
}

@@ -565,24 +565,25 @@
 tMessage();%0A
+%0A
             
@@ -680,16 +680,194 @@
        %7D
+%0A%0A            for (Throwable suppressed : throwable.getSuppressed()) %7B%0A                if (matches(suppressed)) %7B%0A                    return true;%0A                %7D%0A            %7D
 %0A       
@@ -1013,16 +1013,120 @@
 tion) %7B%0A
+        description.appendText(%22message of any exception in the stacktrace to contain: %22 + messagePart);
 %0A    %7D%0A%7D

Fix StackTraceMatcher