onUsageException method

UsageException? onUsageException(
  1. UsageException exception,
  2. UsageOutputHandler usageOutput, {
  3. required CommandDefinition<OptionDefinition>? fromCommand,
})

Implementation

UsageException? onUsageException(
  final UsageException exception,
  final UsageOutputHandler usageOutput, {
  required final CommandDefinition? fromCommand,
}) {
  if (!usageOutput.exceptionSettings.noUsageExceptionOutput) {
    final exceptionPrinter = usageOutput.exceptionSettings.exceptionPrinter;
    exceptionPrinter.printException(
      exception,
      usageOutput: usageOutput,
      fromCommand: fromCommand,
    );
  }
  if (usageOutput.exceptionSettings.noUsageException) {
    return null;
  }
  return exception;
}