exception property

Exception get exception

The exception given when the token was cancelled.

On debug builds this will throw an exception if the token hasn't been called yet. On release builds a fallback CancelledException will be returned to prevent unexpected exceptions.

Implementation

Exception get exception {
  assert(
    isCancelled,
    'Attempted to get the cancellation exception of a $runtimeType that '
    'hasn\'t been cancelled yet.',
  );
  return _exception ??= CancelledException();
}