Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change parse_args readme and samples to catch const std::exception& #294

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) {
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down Expand Up @@ -137,7 +137,7 @@ program.add_argument("--verbose")
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -203,7 +203,7 @@ program.add_argument("--color")
try {
program.parse_args(argc, argv); // Example: ./main --color orange
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand All @@ -226,7 +226,7 @@ program.add_argument("--color")
try {
program.parse_args(argc, argv); // Example: ./main --color red --color green --color blue
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -274,7 +274,7 @@ program.add_argument("floats")
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -307,7 +307,7 @@ program.add_argument("--verbose")
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -407,7 +407,7 @@ program.add_argument("--input_files")
try {
program.parse_args(argc, argv); // Example: ./main --input_files config.yml System.xml
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -436,7 +436,7 @@ program.add_argument("--query_point")
try {
program.parse_args(argc, argv); // Example: ./main --query_point 3.5 4.7 9.2
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -491,7 +491,7 @@ program.add_argument("-c")
try {
program.parse_args(argc, argv); // Example: ./main -abc 1.95 2.47
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -604,7 +604,7 @@ program.add_argument("files")
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -651,7 +651,7 @@ program.add_argument("files")
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -777,7 +777,7 @@ int main(int argc, char *argv[]) {
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down Expand Up @@ -904,7 +904,7 @@ int main(int argc, char *argv[]) {
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down Expand Up @@ -952,7 +952,7 @@ int main(int argc, char *argv[]) {
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down Expand Up @@ -993,7 +993,7 @@ program.add_argument("config")
try {
program.parse_args({"./test", "config.json"});
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -1029,7 +1029,7 @@ program.add_argument("--files")
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -1071,7 +1071,7 @@ program.add_argument("input")
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
std::exit(1);
Expand Down Expand Up @@ -1100,7 +1100,7 @@ int main(int argc, char *argv[]) {
try {
program.parse_args(argc, argv);
}
catch (const std::runtime_error& err) {
catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/compound_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv); // Example: ./main -abc 1.95 2.47
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/custom_assignment_characters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/custom_prefix_characters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/gathering_remaining_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/is_used.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv); // Example: ./main --color orange
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/joining_repeated_optional_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
try {
program.parse_args(
argc, argv); // Example: ./main --color red --color green --color blue
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/list_of_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
try {
program.parse_args(
argc, argv); // Example: ./main --input_files config.yml System.xml
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/negative_numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/optional_flag_argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/positional_argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/required_optional_argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion samples/subcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {

try {
program.parse_args(argc, argv);
} catch (const std::runtime_error &err) {
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
Expand Down
Loading