PromptException class sealed

Why a prompt returned no answer.

Sealed so that a caller tells the two apart exhaustively: a person who walked away (PromptCancelledException) is not a run that nobody could be asked in (PromptAnswerRequiredException). A command line ends the first quietly and turns the second into "pass --flag".

Future<void> run(Cli cli) async {
  try {
    await cli.confirm('Overwrite?');
  } on PromptException catch (e) {
    switch (e) {
      case PromptCancelledException():
        cli.info('Cancelled.');
      case PromptAnswerRequiredException(:final question):
        cli.err('"$question" needs --yes where nobody can answer');
    }
  }
}
Implemented types
Implementers

Properties

hashCode → int
The hash code for this object.
no setterinherited
question → String
The question that went unanswered, as the prompt was given it.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited