Just thoughts that it will be better to make Cance...
# coroutines
p
Just thoughts that it will be better to make Cancellation exception extends from Throwable. Normal exception handling will be with less code to write without checking case of Cancelation exception.
j
Normal exception handling code shouldn't catch
CancellationException
, though 🤔 (it shouldn't catch
Exception
in general). I mean, assuming that "normal" means regular business code, not framework code (in framework code that would make sense, but then it's just one
ensureActive()
call in the catch block).
p
By normal I mean not Error and CancellationException. I agree that catching base Exception is not tight way, but there are some cases. For examle logging or framework logic. Almost in every such case it is needed to filter out CancellatiinException.
j
There should be only a limited number of places that handle "all errors" generally like this, and usually this is in framework code. If you need to "exclude CancellationException", you should use
ensureActive()
instead of 2 catch blocks.