cli11
Loading...
Searching...
No Matches
error.cpp File Reference
module cli11

The exception hierarchy thrown by the library. More...

import cli11:string_tools;
import std;

Classes

class  cli::error_t
 Base of every exception the library throws. More...
class  cli::detail::error_mixin_t< derived_t, base_t >
 Supplies the constructor set every error type shares. More...
class  cli::construction_error_t
 Base of the errors reporting a mistake in how the parser was built. More...
class  cli::incorrect_construction_t
 An option was configured in a way that cannot work. More...
class  cli::bad_name_string_t
 An option, subcommand, or positional name was malformed. More...
class  cli::option_already_added_t
 A name collided with one already registered. More...
class  cli::parse_error_t
 Base of the errors reporting a problem with the command line. More...
class  cli::success_t
 Parsing finished early but successfully; the program should exit cleanly. More...
class  cli::call_for_help_t
 The help flag was given; print help and exit. More...
class  cli::call_for_all_help_t
 The expanded help flag was given; print full help and exit. More...
class  cli::call_for_version_t
 The version flag was given; print the version and exit. More...
class  cli::runtime_error_t
 The program requested a non-zero exit without a parsing problem. More...
class  cli::file_error_t
 A file could not be opened or read. More...
class  cli::conversion_error_t
 A value could not be converted to the option's target type. More...
class  cli::validation_error_t
 A value failed one of the option's validators. More...
class  cli::required_error_t
 A required option or subcommand was not supplied. More...
class  cli::argument_mismatch_t
 An option received the wrong number of values. More...
class  cli::requires_error_t
 An option was used without another it depends on. More...
class  cli::excludes_error_t
 Two mutually exclusive options were used together. More...
class  cli::extras_error_t
 Arguments remained on the command line after parsing finished. More...
class  cli::config_error_t
 A configuration file could not be parsed or applied. More...
class  cli::invalid_error_t
 The parser reached a state it cannot resolve. More...
class  cli::horrible_error_t
 An internal invariant was violated. More...
class  cli::option_not_found_t
 A lookup by name found no matching option. More...

Enumerations

enum class  cli::exit_codes_t : int {
  success = 0 , incorrect_construction = 100 , bad_name_string , option_already_added ,
  file_error , conversion_error , validation_error , required_error ,
  requires_error , excludes_error , extras_error , config_error ,
  invalid_error , horrible_error , option_not_found , argument_mismatch ,
  base_class = 127
}
 Process exit codes associated with each error type. More...

Detailed Description

The exception hierarchy thrown by the library.

Everything derives from cli::error_t, which derives from std::runtime_error. The hierarchy splits into two branches:

  • cli::construction_error_t and its descendants report programmer mistakes made while building the parser, and are thrown from add_option and friends.
  • cli::parse_error_t and its descendants report problems with the command line itself, and are thrown from parse.

Catch cli::parse_error_t in main and hand it to app_t::exit.

Each type carries a short name, reachable through cli::error_t::get_name, and a process exit code, reachable through cli::error_t::get_exit_code.

Enumeration Type Documentation

◆ exit_codes_t

enum class cli::exit_codes_t : int
exportstrong

Process exit codes associated with each error type.

Enumerator
success 

No error.

incorrect_construction 

The parser was built incorrectly.

bad_name_string 

An option or subcommand name was malformed.

option_already_added 

A name collided with an existing option.

file_error 

A file could not be read.

conversion_error 

A value could not be converted to its target type.

validation_error 

A value failed a validator.

required_error 

A required option or subcommand was absent.

requires_error 

An option was used without one it depends on.

excludes_error 

Two mutually exclusive options were used together.

extras_error 

Unexpected arguments remained after parsing.

config_error 

A configuration file could not be applied.

invalid_error 

The parser reached an invalid state.

horrible_error 

An internal invariant was violated; please report it.

option_not_found 

A lookup by name found no such option.

argument_mismatch 

An option received the wrong number of arguments.

base_class 

Default for an otherwise unclassified error.