validateRequest method

void validateRequest(
  1. StateTransactionOperation operation, {
  2. required bool quiescent,
})

Rejects an unsupported or insufficiently quiesced request.

Implementation

void validateRequest(
  StateTransactionOperation operation, {
  required bool quiescent,
}) {
  final supported = switch (operation) {
    StateTransactionOperation.snapshot => supportsSnapshot,
    StateTransactionOperation.restore => supportsRestore,
  };
  if (!supported) {
    throw UnsupportedError(
        '${operation.name} state transactions are not supported.');
  }
  if (requiresQuiescence(operation) && !quiescent) {
    throw StateError(
        '${operation.name} requires the component to be quiescent.');
  }
}