Add orElseThrow
udalrich opened this issue · comments
It would be good to be able to do something like
int len =
whenTypeOf(x).
is(String.class).
thenReturn(s -> s.length()).
is(Collection.class).
thenReturn(c -> c.size()).
orElseThrow(o -> new RuntimeException("My custom message about"+ o));
so that, if the input object is not a type that I handle, I can generate the exception that I want.