core / pragma.utils / cancellationCheck /
cancellationCheck #
fun CoroutineScope.cancellationCheck(logger: Logger, format: String, vararg arguments: Any?)
Checks the cancellation status of the coroutine. If the coroutine is active, this function is a no-op. If the coroutine is cancelled, logs a debug message and throws a CancellationException.
This can be useful when catching Exceptions to handle CancellationExceptions correctly when a coroutine is being cancelled.
Sample Usage: cancellationCheck(logger, "Coroutine Cancelled while retrieving data for gamePlayerId: {}", gamePlayerId)
Parameters #
logger | Used to log the debug message when the coroutine context is not active. |
format | The debug message to log if the coroutine context has been cancelled. |
arguments | Additional arguments to be included in the debug log message. |
fun CoroutineContext.cancellationCheck(logger: Logger, format: String, vararg arguments: Any?)
Checks the cancellation status of the coroutine context. If the coroutine context is active, this function is a no-op. If the coroutine context is cancelled, logs a debug message and throws a CancellationException.
This can be useful when catching Exceptions to handle CancellationExceptions correctly when a coroutine is being cancelled.
Sample Usage: coroutineContext.cancellationCheck(logger, "Coroutine Cancelled while retrieving data for gamePlayerId: {}", gamePlayerId)
Parameters #
logger | Used to log the debug message when the coroutine context is not active. |
format | The debug message to log if the coroutine context has been cancelled. |
arguments | Additional arguments to be included in the debug log message. |