It looks like you're looking for catchThrowableOfType, which allows you to receive the correct class:

import static org.assertj.core.api.Assertions.catchThrowableOfType;

SomeException throwable = catchThrowableOfType(() -> service.doSomething(), SomeException.class);

assertThat(throwable.getSomething()).isNotNull();

This post was filed under replies.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.