fun catch(f: () -> Unit): Throwable?
Platform and version requirements: Common
Catches any exceptions thrown in the given lambda and returns it. This is an easy way to assert on expected thrown exceptions.
val exception = catch { throw Exception("error") }
assertThat(exception).isNotNull().hasMessage("error")