onUsageException method

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

Handles a usage exception by invoking the registered exception handlers. Returns the exception if it shall be rethrown, or null if it is suppressed.

Implementation

UsageException? onUsageException(
  UsageException exception, {
  required final CommandDefinition? fromCommand,
}) {
  for (final handler in exceptionHandlers) {
    final e = handler(exception, this, fromCommand: fromCommand);
    if (e == null) return null;
    exception = e;
  }
  return exception;
}