withTimeout() throws a
TimeoutCancellationException. If you need to do
work in case of a timeout, you can wrap the
and catch the
In the previous lesson, if you run the code, you never see the "This is printed after the timeout"
message. That is because
withTimeout() threw the
That was caught by the
launch() code, bypassing our "after the timeout"
call. However, in this lesson, since we are catching the
you will see both the "We got a timeout exception" message and the
"This is printed after the timeout" message.