7 #include "arg_router/basic_types.hpp"
8 #include "arg_router/traits.hpp"
9 #include "arg_router/utility/exception_formatter.hpp"
68 using error_code_translations = std::tuple<
69 std::pair<traits::integral_constant<error_code::unknown_argument>,
70 AR_STRING(
"Unknown argument")>,
71 std::pair<traits::integral_constant<error_code::unhandled_arguments>,
72 AR_STRING(
"Unhandled arguments")>,
73 std::pair<traits::integral_constant<error_code::argument_has_already_been_set>,
74 AR_STRING(
"Argument has already been set")>,
75 std::pair<traits::integral_constant<error_code::failed_to_parse>,
76 AR_STRING(
"Failed to parse")>,
77 std::pair<traits::integral_constant<error_code::no_arguments_passed>,
78 AR_STRING(
"No arguments passed")>,
79 std::pair<traits::integral_constant<error_code::minimum_value_not_reached>,
80 AR_STRING(
"Minimum value not reached")>,
81 std::pair<traits::integral_constant<error_code::maximum_value_exceeded>,
82 AR_STRING(
"Maximum value exceeded")>,
83 std::pair<traits::integral_constant<error_code::minimum_count_not_reached>,
84 AR_STRING(
"Minimum count not reached")>,
85 std::pair<traits::integral_constant<error_code::maximum_count_exceeded>,
86 AR_STRING(
"Maximum count exceeded")>,
87 std::pair<traits::integral_constant<error_code::unknown_argument_with_suggestion>,
88 AR_STRING(
"Unknown argument: {}. Did you mean { }?")>,
89 std::pair<traits::integral_constant<error_code::mode_requires_arguments>,
90 AR_STRING(
"Mode requires arguments")>,
91 std::pair<traits::integral_constant<error_code::missing_required_argument>,
92 AR_STRING(
"Missing required argument")>,
93 std::pair<traits::integral_constant<error_code::too_few_values_for_alias>,
94 AR_STRING(
"Too few values for alias")>,
95 std::pair<traits::integral_constant<error_code::dependent_argument_missing>,
96 AR_STRING(
"Dependent argument missing (needs to be before the "
97 "requiring token on the command line)")>,
98 std::pair<traits::integral_constant<error_code::one_of_selected_type_mismatch>,
99 AR_STRING(
"Only one argument from a \"One Of\" can be used at once")>,
100 std::pair<traits::integral_constant<error_code::missing_value_separator>,
101 AR_STRING(
"Expected a value separator")>>;
180 message_{message +
": " + parsing::to_string(token)}
190 template <
typename S>
193 message_{cts.
format(tokens)}
197 [[nodiscard]]
const char* what() const noexcept
override {
return message_.data(); }
error_code ec() const noexcept
multi_lang_exception(error_code ec, vector< parsing::token_type > tokens) noexcept
multi_lang_exception(error_code ec, const parsing::token_type &token)
multi_lang_exception(error_code ec) noexcept
const vector< parsing::token_type > & tokens() const noexcept
parse_exception(utility::exception_formatter< S > cts, const vector< parsing::token_type > &tokens={})
parse_exception(const string &message, const parsing::token_type &token)
parse_exception(const string &message, const vector< parsing::token_type > &tokens={})
constexpr std::string_view to_string(prefix_type prefix) noexcept
std::vector< T, config::allocator< T > > vector
@ minimum_count_not_reached
Minimum number of value tokens for node not reached.
@ failed_to_parse
A value token could not be converted into its target value.
@ dependent_argument_missing
@ unknown_argument_with_suggestion
@ maximum_count_exceeded
Maximum number of value tokens exceeded.
@ one_of_selected_type_mismatch
@ missing_required_argument
A node has been marked as required but no token matches it.
@ minimum_value_not_reached
Parsed value is below the minimum.
@ missing_value_separator
@ argument_has_already_been_set
@ mode_requires_arguments
@ too_few_values_for_alias
@ maximum_value_exceeded
Parsed value is above the maximum.