Skip to main content
Module

x/cliffy/command/command.ts>Command#throwErrors

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
method Command.prototype.throwErrors
import { Command } from "https://deno.land/x/cliffy@v0.24.2/command/command.ts";

Throw validation errors instead of calling Deno.exit() to handle validation errors manually.

A validation error is thrown when the command is wrongly used by the user. For example: If the user passes some invalid options or arguments to the command.

This has no effect for parent commands. Only for the command on which this method was called and all child commands.

Example:

try {
  cmd.parse();
} catch(error) {
  if (error instanceof ValidationError) {
    cmd.showHelp();
    Deno.exit(1);
  }
  throw error;
}