<E extends Throwable> E expecting(Class<E> cls, TemperamentalRunnable action) {
		try {
			action.run();
		}
		catch (Throwable e) {
			if (cls.isInstance(e)) {
				return cls.cast(e);
			}
			throw new AssertionError("Expection exception type " + cls + ", but got " + e, e);
		}
		throw new AssertionError("Expected exception type " + cls + ", but got no error.");
	}
Verify that the given action (usually a lambda) throws an exception

<p>
This fulfills the same use case as the {@link Test#expected()} attribute, but allows more
precise verification of which code in the test causes the exception.
Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/control/DebuggerControlServiceTest.java