You can call invokeOnCompletion() on a Job and register a lambda to be evaluated when the job is completed for any reason. The parameter passed to the lambda will be:

  • null if the job completed normally
  • a CancellationException (or subclass) if the job was canceled
  • some other type of exception if the job failed

Note that this lambda could be executed on any thread. As the documentation states, this lambda "must be fast, non-blocking, and thread-safe".

You can learn more about this in:
Run Edit