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 get the following confusing error messages:
> ./my-app --port abc
pattern 'abc' not found
> ./my-app --port 1.5
pattern '1.5' does not match to the end
The problems:
The name of the argument being parsed is not included in the error message.
"pattern {value}" is incorrect; the pattern is what we are searching for, but we print the value we got instead. This could be changed to "pattern for {shape}" (accurate, but perhaps not super useful to the user if they don't know what the shape 'u' actually means). Ideally we would print both the value and the shape though, for example "value 'abc' does not match expected format ('u')".
if (auto [ok, rest] = consume_binary_prefix(s); ok) {
return do_from_chars<T, radix_2>(rest);
}
throw std::invalid_argument{"pattern not found"};
}
};
The specialization of this struct for radix_16 has try/catch blocks to intercept the low-level exception from do_from_chars to convert them to better messages (e.g. "Failed to parse {value} as hexadecimal: {reason}"). But the default parse_number (and the one for radix_2) do not. Still, none of the functions (even radix_16 which tried harder) include the name of the argument that failed parsing.
The text was updated successfully, but these errors were encountered:
Currently, if trying to parse an
'u'
-shaped integer... we get the following confusing error messages:
The problems:
'u'
actually means). Ideally we would print both the value and the shape though, for example "value 'abc' does not match expected format ('u')".It seems the issue could be here
argparse/include/argparse/argparse.hpp
Lines 246 to 259 in af442b4
The specialization of this struct for
radix_16
hastry
/catch
blocks to intercept the low-level exception fromdo_from_chars
to convert them to better messages (e.g. "Failed to parse {value} as hexadecimal: {reason}"). But the defaultparse_number
(and the one forradix_2
) do not. Still, none of the functions (evenradix_16
which tried harder) include the name of the argument that failed parsing.The text was updated successfully, but these errors were encountered: