You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using CLI11 for an app. We have done a lot of tinkering with the output. One of the things we ran into during this was the lack of control for the formatting of exceptions. A lot of my problems are similar to the problems mentioned in issue 167
Take the following code in app.cpp:
if(min_num > collected) { // if we have run out of arguments and the minimum was not metthrowArgumentMismatch::TypedAtLeast(op->get_name(), min_num, op->get_type_name());
}
CLI11_ERROR_DEF(ParseError, ArgumentMismatch)
CLI11_ERROR_SIMPLE(ArgumentMismatch)
ArgumentMismatch(std::string name, int expected, std::size_t received)
: ArgumentMismatch(expected > 0 ? ("Expected exactly " + std::to_string(expected) + " arguments to " + name +
", got " + std::to_string(received))
: ("Expected at least " + std::to_string(-expected) + " arguments to " + name +
", got " + std::to_string(received)),
ExitCodes::ArgumentMismatch) {}
static ArgumentMismatch AtLeast(std::string name, int num, std::size_t received) {
returnArgumentMismatch(name + ": At least " + std::to_string(num) + " required but received " +
std::to_string(received));
}
As you can see here, the entire context is essentially lost as everything is combined into a string, making it incredibly difficult to modify this at a later stage.
So, for me, the solution would be either what is mentioned in the original issue and store information in the exception about the context, or what I think would be even better is to allow the user, like for many other things, to specify a callback for these default build in errors. So, the user gets the ability to build the desired output format.
The text was updated successfully, but these errors were encountered:
We are using CLI11 for an app. We have done a lot of tinkering with the output. One of the things we ran into during this was the lack of control for the formatting of exceptions. A lot of my problems are similar to the problems mentioned in issue 167
Take the following code in app.cpp:
As you can see here, the entire context is essentially lost as everything is combined into a string, making it incredibly difficult to modify this at a later stage.
So, for me, the solution would be either what is mentioned in the original issue and store information in the exception about the context, or what I think would be even better is to allow the user, like for many other things, to specify a callback for these default build in errors. So, the user gets the ability to build the desired output format.
The text was updated successfully, but these errors were encountered: