mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 22:54:39 +00:00
Throw std::logic_error instead of returning empty value
This commit is contained in:
parent
02b3ed1878
commit
f08a280f92
@ -304,7 +304,7 @@ class ArgumentParser {
|
||||
if (tIterator != mArgumentMap.end()) {
|
||||
return tIterator->second->get<T>();
|
||||
}
|
||||
return T();
|
||||
throw std::logic_error("No such argument");
|
||||
}
|
||||
|
||||
// Indexing operator. Return a reference to an Argument object
|
||||
@ -314,9 +314,7 @@ class ArgumentParser {
|
||||
if (tIterator != mArgumentMap.end()) {
|
||||
return *(tIterator->second);
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("Argument " + aArgumentName + " not found");
|
||||
}
|
||||
throw std::logic_error("No such argument");
|
||||
}
|
||||
|
||||
// Printing the one and only help message
|
||||
@ -390,12 +388,6 @@ class ArgumentParser {
|
||||
}
|
||||
|
||||
private:
|
||||
// If the argument was defined by the user and can be found in mArgumentMap, then it's valid
|
||||
bool is_valid_argument(const std::string& aName) {
|
||||
auto tIterator = mArgumentMap.find(aName);
|
||||
return (tIterator != mArgumentMap.end());
|
||||
}
|
||||
|
||||
/*
|
||||
* @throws std::runtime_error in case of any invalid argument
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user