Fixes #345, fixes #346, regards #340: Put exceptions in a sub-namespace and renamed them accordingly.

* Also fixed some "loose ends" regarding namespace indentation which were missing in PR #350.
This commit is contained in:
Eyal Rozenberg 2022-07-08 23:42:12 +03:00
parent fbd79df66b
commit 2e708c02c6
5 changed files with 345 additions and 335 deletions

View File

@ -109,9 +109,9 @@ result.unmatched()
Exceptional situations throw C++ exceptions. There are two types of Exceptional situations throw C++ exceptions. There are two types of
exceptions: errors defining the options, and errors when parsing a list of exceptions: errors defining the options, and errors when parsing a list of
arguments. All exceptions derive from `cxxopts::OptionException`. Errors arguments. All exceptions derive from `cxxopts::exceptions::exception`. Errors
defining options derive from `cxxopts::OptionSpecException` and errors defining options derive from `cxxopts::exceptions::specification` and errors
parsing arguments derive from `cxxopts::OptionParseException`. parsing arguments derive from `cxxopts::exceptions::parsing`.
All exceptions define a `what()` function to get a printable string All exceptions define a `what()` function to get a printable string
explaining the error. explaining the error.

View File

@ -227,6 +227,7 @@ empty(const String& s)
} // namespace cxxopts } // namespace cxxopts
namespace std { namespace std {
inline inline
cxxopts::UnicodeStringIterator cxxopts::UnicodeStringIterator
begin(const icu::UnicodeString& s) begin(const icu::UnicodeString& s)
@ -304,6 +305,7 @@ empty(const std::string& s)
#endif #endif
namespace cxxopts { namespace cxxopts {
namespace { namespace {
#ifdef _WIN32 #ifdef _WIN32
const std::string LQUOTE("\'"); const std::string LQUOTE("\'");
@ -368,10 +370,11 @@ class Value : public std::enable_shared_from_this<Value>
#if defined(__GNUC__) #if defined(__GNUC__)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
class OptionException : public std::exception namespace exceptions {
class exception : public std::exception
{ {
public: public:
explicit OptionException(std::string message) explicit exception(std::string message)
: m_message(std::move(message)) : m_message(std::move(message))
{ {
} }
@ -387,92 +390,92 @@ class OptionException : public std::exception
std::string m_message; std::string m_message;
}; };
class OptionSpecException : public OptionException class specification : public exception
{ {
public: public:
explicit OptionSpecException(const std::string& message) explicit specification(const std::string& message)
: OptionException(message) : exception(message)
{ {
} }
}; };
class OptionParseException : public OptionException class parsing : public exception
{ {
public: public:
explicit OptionParseException(const std::string& message) explicit parsing(const std::string& message)
: OptionException(message) : exception(message)
{ {
} }
}; };
class option_exists_error : public OptionSpecException class option_already_exists : public specification
{ {
public: public:
explicit option_exists_error(const std::string& option) explicit option_already_exists(const std::string& option)
: OptionSpecException("Option " + LQUOTE + option + RQUOTE + " already exists") : specification("Option " + LQUOTE + option + RQUOTE + " already exists")
{ {
} }
}; };
class invalid_option_format_error : public OptionSpecException class invalid_option_format : public specification
{ {
public: public:
explicit invalid_option_format_error(const std::string& format) explicit invalid_option_format(const std::string& format)
: OptionSpecException("Invalid option format " + LQUOTE + format + RQUOTE) : specification("Invalid option format " + LQUOTE + format + RQUOTE)
{ {
} }
}; };
class option_syntax_exception : public OptionParseException { class invalid_option_syntax : public parsing {
public: public:
explicit option_syntax_exception(const std::string& text) explicit invalid_option_syntax(const std::string& text)
: OptionParseException("Argument " + LQUOTE + text + RQUOTE + : parsing("Argument " + LQUOTE + text + RQUOTE +
" starts with a - but has incorrect syntax") " starts with a - but has incorrect syntax")
{ {
} }
}; };
class option_not_exists_exception : public OptionParseException class no_such_option : public parsing
{ {
public: public:
explicit option_not_exists_exception(const std::string& option) explicit no_such_option(const std::string& option)
: OptionParseException("Option " + LQUOTE + option + RQUOTE + " does not exist") : parsing("Option " + LQUOTE + option + RQUOTE + " does not exist")
{ {
} }
}; };
class missing_argument_exception : public OptionParseException class missing_argument : public parsing
{ {
public: public:
explicit missing_argument_exception(const std::string& option) explicit missing_argument(const std::string& option)
: OptionParseException( : parsing(
"Option " + LQUOTE + option + RQUOTE + " is missing an argument" "Option " + LQUOTE + option + RQUOTE + " is missing an argument"
) )
{ {
} }
}; };
class option_requires_argument_exception : public OptionParseException class option_requires_argument : public parsing
{ {
public: public:
explicit option_requires_argument_exception(const std::string& option) explicit option_requires_argument(const std::string& option)
: OptionParseException( : parsing(
"Option " + LQUOTE + option + RQUOTE + " requires an argument" "Option " + LQUOTE + option + RQUOTE + " requires an argument"
) )
{ {
} }
}; };
class option_not_has_argument_exception : public OptionParseException class gratuitous_argument_for_option : public parsing
{ {
public: public:
option_not_has_argument_exception gratuitous_argument_for_option
( (
const std::string& option, const std::string& option,
const std::string& arg const std::string& arg
) )
: OptionParseException( : parsing(
"Option " + LQUOTE + option + RQUOTE + "Option " + LQUOTE + option + RQUOTE +
" does not take an argument, but argument " + " does not take an argument, but argument " +
LQUOTE + arg + RQUOTE + " given" LQUOTE + arg + RQUOTE + " given"
@ -481,20 +484,20 @@ class option_not_has_argument_exception : public OptionParseException
} }
}; };
class option_not_present_exception : public OptionParseException class requested_option_not_present : public parsing
{ {
public: public:
explicit option_not_present_exception(const std::string& option) explicit requested_option_not_present(const std::string& option)
: OptionParseException("Option " + LQUOTE + option + RQUOTE + " not present") : parsing("Option " + LQUOTE + option + RQUOTE + " not present")
{ {
} }
}; };
class option_has_no_value_exception : public OptionException class option_has_no_value : public exception
{ {
public: public:
explicit option_has_no_value_exception(const std::string& option) explicit option_has_no_value(const std::string& option)
: OptionException( : exception(
!option.empty() ? !option.empty() ?
("Option " + LQUOTE + option + RQUOTE + " has no value") : ("Option " + LQUOTE + option + RQUOTE + " has no value") :
"Option has no value") "Option has no value")
@ -502,30 +505,31 @@ class option_has_no_value_exception : public OptionException
} }
}; };
class argument_incorrect_type : public OptionParseException class incorrect_argument_type : public parsing
{ {
public: public:
explicit argument_incorrect_type explicit incorrect_argument_type
( (
const std::string& arg const std::string& arg
) )
: OptionParseException( : parsing(
"Argument " + LQUOTE + arg + RQUOTE + " failed to parse" "Argument " + LQUOTE + arg + RQUOTE + " failed to parse"
) )
{ {
} }
}; };
class option_required_exception : public OptionParseException class required_option_missing : public parsing
{ {
public: public:
explicit option_required_exception(const std::string& option) explicit required_option_missing(const std::string& option)
: OptionParseException( : parsing(
"Option " + LQUOTE + option + RQUOTE + " is required but not present" "Option " + LQUOTE + option + RQUOTE + " is required but not present"
) )
{ {
} }
}; };
}
template <typename T> template <typename T>
void throw_or_mimic(const std::string& text) void throw_or_mimic(const std::string& text)
@ -547,7 +551,9 @@ void throw_or_mimic(const std::string& text)
} }
namespace values { namespace values {
namespace parser_tool { namespace parser_tool {
struct IntegerDesc struct IntegerDesc
{ {
std::string negative = ""; std::string negative = "";
@ -560,12 +566,13 @@ struct ArguDesc {
bool set_value = false; bool set_value = false;
std::string value = ""; std::string value = "";
}; };
#ifdef CXXOPTS_NO_REGEX #ifdef CXXOPTS_NO_REGEX
inline IntegerDesc SplitInteger(const std::string &text) inline IntegerDesc SplitInteger(const std::string &text)
{ {
if (text.empty()) if (text.empty())
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
IntegerDesc desc; IntegerDesc desc;
const char *pdata = text.c_str(); const char *pdata = text.c_str();
@ -585,7 +592,7 @@ inline IntegerDesc SplitInteger(const std::string &text)
} }
else else
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
return desc; return desc;
} }
@ -644,7 +651,7 @@ inline std::pair<std::string, std::string> SplitSwitchDef(const std::string &tex
if (*pdata == '\0') { if (*pdata == '\0') {
long_sw = std::string(store, pdata - store); long_sw = std::string(store, pdata - store);
} else { } else {
throw_or_mimic<invalid_option_format_error>(text); throw_or_mimic<exceptions::invalid_option_format>(text);
} }
} }
return std::pair<std::string, std::string>(short_sw, long_sw); return std::pair<std::string, std::string>(short_sw, long_sw);
@ -725,7 +732,7 @@ inline IntegerDesc SplitInteger(const std::string &text)
if (match.length() == 0) if (match.length() == 0)
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
IntegerDesc desc; IntegerDesc desc;
@ -741,7 +748,6 @@ inline IntegerDesc SplitInteger(const std::string &text)
} }
return desc; return desc;
} }
inline bool IsTrueText(const std::string &text) inline bool IsTrueText(const std::string &text)
@ -764,7 +770,7 @@ inline std::pair<std::string, std::string> SplitSwitchDef(const std::string &tex
std::regex_match(text.c_str(), result, option_specifier); std::regex_match(text.c_str(), result, option_specifier);
if (result.empty()) if (result.empty())
{ {
throw_or_mimic<invalid_option_format_error>(text); throw_or_mimic<exceptions::invalid_option_format>(text);
} }
const std::string& short_sw = result[2]; const std::string& short_sw = result[2];
@ -799,6 +805,7 @@ inline ArguDesc ParseArgument(const char *arg, bool &matched)
} // namespace parser_tool } // namespace parser_tool
namespace detail { namespace detail {
template <typename T, bool B> template <typename T, bool B>
struct SignedCheck; struct SignedCheck;
@ -813,14 +820,14 @@ struct SignedCheck<T, true>
{ {
if (u > static_cast<U>((std::numeric_limits<T>::min)())) if (u > static_cast<U>((std::numeric_limits<T>::min)()))
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
} }
else else
{ {
if (u > static_cast<U>((std::numeric_limits<T>::max)())) if (u > static_cast<U>((std::numeric_limits<T>::max)()))
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
} }
} }
@ -857,7 +864,7 @@ template <typename R, typename T>
void void
checked_negate(R&, T&&, const std::string& text, std::false_type) checked_negate(R&, T&&, const std::string& text, std::false_type)
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
template <typename T> template <typename T>
@ -893,13 +900,13 @@ integer_parser(const std::string& text, T& value)
} }
else else
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
const US next = static_cast<US>(result * base + digit); const US next = static_cast<US>(result * base + digit);
if (result > next) if (result > next)
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
result = next; result = next;
@ -923,7 +930,7 @@ void stringstream_parser(const std::string& text, T& value)
std::stringstream in(text); std::stringstream in(text);
in >> value; in >> value;
if (!in) { if (!in) {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
} }
@ -951,7 +958,7 @@ parse_value(const std::string& text, bool& value)
return; return;
} }
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
inline inline
@ -1007,7 +1014,7 @@ void parse_value(const std::string& text, char& c)
{ {
if (text.length() != 1) if (text.length() != 1)
{ {
throw_or_mimic<argument_incorrect_type>(text); throw_or_mimic<exceptions::incorrect_argument_type>(text);
} }
c = text[0]; c = text[0];
@ -1204,6 +1211,7 @@ class standard_value<bool> : public abstract_value<bool>
m_implicit_value = "true"; m_implicit_value = "true";
} }
}; };
} // namespace values } // namespace values
template <typename T> template <typename T>
@ -1388,7 +1396,7 @@ class OptionValue
as() const as() const
{ {
if (m_value == nullptr) { if (m_value == nullptr) {
throw_or_mimic<option_has_no_value_exception>( throw_or_mimic<exceptions::option_has_no_value>(
m_long_name == nullptr ? "" : *m_long_name); m_long_name == nullptr ? "" : *m_long_name);
} }
@ -1576,14 +1584,14 @@ class ParseResult
if (iter == m_keys.end()) if (iter == m_keys.end())
{ {
throw_or_mimic<option_not_present_exception>(option); throw_or_mimic<exceptions::requested_option_not_present>(option);
} }
auto viter = m_values.find(iter->second); auto viter = m_values.find(iter->second);
if (viter == m_values.end()) if (viter == m_values.end())
{ {
throw_or_mimic<option_not_present_exception>(option); throw_or_mimic<exceptions::requested_option_not_present>(option);
} }
return viter->second; return viter->second;
@ -1898,6 +1906,7 @@ class OptionAdder
}; };
namespace { namespace {
constexpr size_t OPTION_LONGEST = 30; constexpr size_t OPTION_LONGEST = 30;
constexpr size_t OPTION_DESC_GAP = 2; constexpr size_t OPTION_DESC_GAP = 2;
@ -2076,6 +2085,7 @@ namespace {
return result; return result;
} }
} // namespace } // namespace
inline inline
@ -2115,11 +2125,11 @@ OptionAdder::operator()
if (!short_sw.length() && !long_sw.length()) if (!short_sw.length() && !long_sw.length())
{ {
throw_or_mimic<invalid_option_format_error>(opts); throw_or_mimic<exceptions::invalid_option_format>(opts);
} }
else if (long_sw.length() == 1 && short_sw.length()) else if (long_sw.length() == 1 && short_sw.length())
{ {
throw_or_mimic<invalid_option_format_error>(opts); throw_or_mimic<exceptions::invalid_option_format>(opts);
} }
auto option_names = [] auto option_names = []
@ -2201,7 +2211,7 @@ OptionParser::checked_parse_arg
} }
else else
{ {
throw_or_mimic<missing_argument_exception>(name); throw_or_mimic<exceptions::missing_argument>(name);
} }
} }
else else
@ -2249,7 +2259,7 @@ OptionParser::consume_positional(const std::string& a, PositionalListIterator& n
add_to_option(iter, *next, a); add_to_option(iter, *next, a);
return true; return true;
} }
throw_or_mimic<option_not_exists_exception>(*next); throw_or_mimic<exceptions::no_such_option>(*next);
} }
return false; return false;
@ -2315,7 +2325,7 @@ OptionParser::parse(int argc, const char* const* argv)
// but if it starts with a `-`, then it's an error // but if it starts with a `-`, then it's an error
if (argv[current][0] == '-' && argv[current][1] != '\0') { if (argv[current][0] == '-' && argv[current][1] != '\0') {
if (!m_allow_unrecognised) { if (!m_allow_unrecognised) {
throw_or_mimic<option_syntax_exception>(argv[current]); throw_or_mimic<exceptions::invalid_option_syntax>(argv[current]);
} }
} }
@ -2350,7 +2360,7 @@ OptionParser::parse(int argc, const char* const* argv)
continue; continue;
} }
//error //error
throw_or_mimic<option_not_exists_exception>(name); throw_or_mimic<exceptions::no_such_option>(name);
} }
auto value = iter->second; auto value = iter->second;
@ -2373,7 +2383,7 @@ OptionParser::parse(int argc, const char* const* argv)
else else
{ {
//error //error
throw_or_mimic<option_requires_argument_exception>(name); throw_or_mimic<exceptions::option_requires_argument>(name);
} }
} }
} }
@ -2393,7 +2403,7 @@ OptionParser::parse(int argc, const char* const* argv)
continue; continue;
} }
//error //error
throw_or_mimic<option_not_exists_exception>(name); throw_or_mimic<exceptions::no_such_option>(name);
} }
auto opt = iter->second; auto opt = iter->second;
@ -2531,7 +2541,7 @@ Options::add_one_option
if (!in.second) if (!in.second)
{ {
throw_or_mimic<option_exists_error>(option); throw_or_mimic<exceptions::option_already_exists>(option);
} }
} }

View File

@ -182,7 +182,7 @@ parse(int argc, const char* argv[])
} }
std::cout << std::endl; std::cout << std::endl;
} }
catch (const cxxopts::OptionException& e) catch (const cxxopts::exceptions::exception& e)
{ {
std::cout << "error parsing options: " << e.what() << std::endl; std::cout << "error parsing options: " << e.what() << std::endl;
return false; return false;

View File

@ -9188,7 +9188,7 @@ namespace Catch {
// And... Print a result applicable to each result type. // And... Print a result applicable to each result type.
switch( assertionResult.getResultType() ) { switch( assertionResult.getResultType() ) {
case ResultWas::ThrewException: case ResultWas::ThrewException:
m_xml.scopedElement( "Exception" ) m_xml.scopedElement( "exception" )
.writeAttribute( "filename", assertionResult.getSourceInfo().file ) .writeAttribute( "filename", assertionResult.getSourceInfo().file )
.writeAttribute( "line", assertionResult.getSourceInfo().line ) .writeAttribute( "line", assertionResult.getSourceInfo().line )
.writeText( assertionResult.getMessage() ); .writeText( assertionResult.getMessage() );

View File

@ -94,7 +94,7 @@ TEST_CASE("Basic options", "[options]")
CHECK(arguments[2].key() == "value"); CHECK(arguments[2].key() == "value");
CHECK(arguments[3].key() == "av"); CHECK(arguments[3].key() == "av");
CHECK_THROWS_AS(result["nothing"].as<std::string>(), cxxopts::option_has_no_value_exception&); CHECK_THROWS_AS(result["nothing"].as<std::string>(), cxxopts::exceptions::option_has_no_value&);
CHECK(options.program() == "tester"); CHECK(options.program() == "tester");
} }
@ -122,7 +122,7 @@ TEST_CASE("Short options", "[options]")
CHECK(arguments[0].value() == "value"); CHECK(arguments[0].value() == "value");
REQUIRE_THROWS_AS(options.add_options()("", "nothing option"), REQUIRE_THROWS_AS(options.add_options()("", "nothing option"),
cxxopts::invalid_option_format_error&); cxxopts::exceptions::invalid_option_format&);
} }
TEST_CASE("No positional", "[positional]") TEST_CASE("No positional", "[positional]")
@ -235,7 +235,7 @@ TEST_CASE("Positional not valid", "[positional]") {
auto** argv = av.argv(); auto** argv = av.argv();
auto argc = av.argc(); auto argc = av.argc();
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_not_exists_exception&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::no_such_option&);
} }
TEST_CASE("Positional with empty arguments", "[positional]") { TEST_CASE("Positional with empty arguments", "[positional]") {
@ -294,7 +294,7 @@ TEST_CASE("Boolean without implicit value", "[implicit]")
auto** argv = av.argv(); auto** argv = av.argv();
auto argc = av.argc(); auto argc = av.argc();
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::missing_argument_exception&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::missing_argument&);
} }
SECTION("With equal-separated true") { SECTION("With equal-separated true") {
@ -460,7 +460,7 @@ TEST_CASE("Unsigned integers", "[options]")
auto argc = av.argc(); auto argc = av.argc();
options.parse_positional("positional"); options.parse_positional("positional");
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::incorrect_argument_type&);
} }
TEST_CASE("Integer bounds", "[integer]") TEST_CASE("Integer bounds", "[integer]")
@ -497,12 +497,12 @@ TEST_CASE("Overflow on boundary", "[integer]")
int8_t si; int8_t si;
uint8_t ui; uint8_t ui;
CHECK_THROWS_AS((integer_parser("128", si)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("128", si)), cxxopts::exceptions::incorrect_argument_type&);
CHECK_THROWS_AS((integer_parser("-129", si)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("-129", si)), cxxopts::exceptions::incorrect_argument_type&);
CHECK_THROWS_AS((integer_parser("256", ui)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("256", ui)), cxxopts::exceptions::incorrect_argument_type&);
CHECK_THROWS_AS((integer_parser("-0x81", si)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("-0x81", si)), cxxopts::exceptions::incorrect_argument_type&);
CHECK_THROWS_AS((integer_parser("0x80", si)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("0x80", si)), cxxopts::exceptions::incorrect_argument_type&);
CHECK_THROWS_AS((integer_parser("0x100", ui)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("0x100", ui)), cxxopts::exceptions::incorrect_argument_type&);
} }
TEST_CASE("Integer overflow", "[options]") TEST_CASE("Integer overflow", "[options]")
@ -519,11 +519,11 @@ TEST_CASE("Integer overflow", "[options]")
auto argc = av.argc(); auto argc = av.argc();
options.parse_positional("positional"); options.parse_positional("positional");
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::incorrect_argument_type&);
int integer = 0; int integer = 0;
CHECK_THROWS_AS((integer_parser("23423423423", integer)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("23423423423", integer)), cxxopts::exceptions::incorrect_argument_type&);
CHECK_THROWS_AS((integer_parser("234234234234", integer)), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS((integer_parser("234234234234", integer)), cxxopts::exceptions::incorrect_argument_type&);
} }
TEST_CASE("Floats", "[options]") TEST_CASE("Floats", "[options]")
@ -564,7 +564,7 @@ TEST_CASE("Invalid integers", "[integer]") {
auto argc = av.argc(); auto argc = av.argc();
options.parse_positional("positional"); options.parse_positional("positional");
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::argument_incorrect_type&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::incorrect_argument_type&);
} }
TEST_CASE("Booleans", "[boolean]") { TEST_CASE("Booleans", "[boolean]") {
@ -670,7 +670,7 @@ TEST_CASE("Unrecognised options", "[options]") {
auto argc = av.argc(); auto argc = av.argc();
SECTION("Default behaviour") { SECTION("Default behaviour") {
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_not_exists_exception&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::no_such_option&);
} }
SECTION("After allowing unrecognised options") { SECTION("After allowing unrecognised options") {
@ -697,7 +697,7 @@ TEST_CASE("Allow bad short syntax", "[options]") {
auto argc = av.argc(); auto argc = av.argc();
SECTION("Default behaviour") { SECTION("Default behaviour") {
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_syntax_exception&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::invalid_option_syntax&);
} }
SECTION("After allowing unrecognised options") { SECTION("After allowing unrecognised options") {
@ -720,7 +720,7 @@ TEST_CASE("Invalid option syntax", "[options]") {
auto argc = av.argc(); auto argc = av.argc();
SECTION("Default behaviour") { SECTION("Default behaviour") {
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_syntax_exception&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::invalid_option_syntax&);
} }
} }
@ -739,7 +739,7 @@ TEST_CASE("Options empty", "[options]") {
auto** argv = argv_.argv(); auto** argv = argv_.argv();
CHECK(options.groups().empty()); CHECK(options.groups().empty());
CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::option_not_exists_exception&); CHECK_THROWS_AS(options.parse(argc, argv), cxxopts::exceptions::no_such_option&);
} }
TEST_CASE("Initializer list with group", "[options]") { TEST_CASE("Initializer list with group", "[options]") {