Commit 1286a1226e2060ef4badab7374df1f564f106a28
Committed by
Henry Schreiner
1 parent
a958ffec
Nicer error messages
Showing
3 changed files
with
5 additions
and
5 deletions
include/CLI/App.hpp
| @@ -1357,7 +1357,7 @@ class App { | @@ -1357,7 +1357,7 @@ class App { | ||
| 1357 | std::string name; | 1357 | std::string name; |
| 1358 | std::string rest; | 1358 | std::string rest; |
| 1359 | if(!detail::split_short(current, name, rest)) | 1359 | if(!detail::split_short(current, name, rest)) |
| 1360 | - throw HorribleError("Short"); | 1360 | + throw HorribleError("Short parsed but missing! You should not see this"); |
| 1361 | 1361 | ||
| 1362 | auto op_ptr = std::find_if( | 1362 | auto op_ptr = std::find_if( |
| 1363 | std::begin(options_), std::end(options_), [name](const Option_p &opt) { return opt->check_sname(name); }); | 1363 | std::begin(options_), std::end(options_), [name](const Option_p &opt) { return opt->check_sname(name); }); |
| @@ -1437,7 +1437,7 @@ class App { | @@ -1437,7 +1437,7 @@ class App { | ||
| 1437 | std::string name; | 1437 | std::string name; |
| 1438 | std::string value; | 1438 | std::string value; |
| 1439 | if(!detail::split_long(current, name, value)) | 1439 | if(!detail::split_long(current, name, value)) |
| 1440 | - throw HorribleError("Long:" + args.back()); | 1440 | + throw HorribleError("Long parsed but missing (you should not see this):" + args.back()); |
| 1441 | 1441 | ||
| 1442 | auto op_ptr = std::find_if( | 1442 | auto op_ptr = std::find_if( |
| 1443 | std::begin(options_), std::end(options_), [name](const Option_p &v) { return v->check_lname(name); }); | 1443 | std::begin(options_), std::end(options_), [name](const Option_p &v) { return v->check_lname(name); }); |
include/CLI/Ini.hpp
| @@ -106,7 +106,7 @@ inline std::vector<ini_ret_t> parse_ini(const std::string &name) { | @@ -106,7 +106,7 @@ inline std::vector<ini_ret_t> parse_ini(const std::string &name) { | ||
| 106 | 106 | ||
| 107 | std::ifstream input{name}; | 107 | std::ifstream input{name}; |
| 108 | if(!input.good()) | 108 | if(!input.good()) |
| 109 | - throw FileError(name); | 109 | + throw FileError(name + " was not readable (missing?)"); |
| 110 | 110 | ||
| 111 | return parse_ini(input); | 111 | return parse_ini(input); |
| 112 | } | 112 | } |
include/CLI/Option.hpp
| @@ -428,13 +428,13 @@ class Option : public OptionBase<Option> { | @@ -428,13 +428,13 @@ class Option : public OptionBase<Option> { | ||
| 428 | } | 428 | } |
| 429 | 429 | ||
| 430 | if(local_result) | 430 | if(local_result) |
| 431 | - throw ConversionError(get_name() + "=" + detail::join(results_)); | 431 | + throw ConversionError("Could not convert: " + get_name() + "=" + detail::join(results_)); |
| 432 | 432 | ||
| 433 | if(!validators_.empty()) { | 433 | if(!validators_.empty()) { |
| 434 | for(const std::string &result : results_) | 434 | for(const std::string &result : results_) |
| 435 | for(const std::function<bool(std::string)> &vali : validators_) | 435 | for(const std::function<bool(std::string)> &vali : validators_) |
| 436 | if(!vali(result)) | 436 | if(!vali(result)) |
| 437 | - throw ValidationError(get_name() + "=" + result); | 437 | + throw ValidationError("Failed validation: " + get_name() + "=" + result); |
| 438 | } | 438 | } |
| 439 | } | 439 | } |
| 440 | 440 |