completeExceptionally

abstract fun completeExceptionally(exception: Throwable): Boolean(source)

Completes this job exceptionally with a given exception. The result is true if this job was completed as a result of this invocation and false otherwise (if it was already completed). exception parameter is used as an additional debug information that is not handled by any exception handlers.

Subsequent invocations of this function have no effect and always produce false.

This function transitions this job into the cancelled state if it has not been completed or cancelled yet. However, if this job has children, then it transitions into the cancelling state and becomes cancelled once all its children are complete. See Job for details.

It is the responsibility of the caller to properly handle and report the given exception. All the job’s children will receive a CancellationException with the exception as a cause for the sake of diagnosis.