@Test
public void testSubsegmentFunctionExceptionWhenMissingContext() {

    IllegalStateException expectedException = new IllegalStateException("To be thrown by function");
    Function<Subsegment, Void> function = (subsegment) -> {
        throw expectedException;
    };
    AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard()
                                                     .withContextMissingStrategy(new IgnoreErrorContextMissingStrategy())
                                                     .build();
    assertThatThrownBy(() -> recorder.createSubsegment("test", function)).isEqualTo(expectedException);
}